### Home Classes Methods

### In Files

- lib/redcloth/textile_doc.rb
- ext/redcloth_scan/redcloth_scan.c

### Parent

String

### Namespace

- CLASS RedCloth::TextileDoc::ParseError

### Methods

- ::new
- #html_esc
- #latex_esc
- #to
- #to_html
- #to_latex

### Files

- COPYING
- README.rdoc
- Makefile

### Class/Module Index

Quicksearch

- RedCloth
- RedCloth::Formatters
- RedCloth::Formatters::Base
- RedCloth::Formatters::HTML
- RedCloth::Formatters::LATEX
- RedCloth::Formatters::LATEX::Settings
- RedCloth::TextileDoc
- RedCloth::TextileDoc::ParseError
- RedCloth::VERSION
- ERB
- ERB::Util
- Object

No matching classes.

# RedCloth::TextileDoc

### Attributes

filter_classes[RW]

Accessors for setting security restrictions.

This is a nice thing if you're using RedCloth for formatting in public places (e.g. Wikis) where you don't want users to abuse HTML for bad things.

If `:filter_html` is set, HTML which wasn't created by the Textile processor will be escaped. Alternatively, if `:sanitize_html` is set, HTML can pass through the Textile processor but unauthorized tags and attributes will be removed.

If `:filter_styles` is set, it will also disable the style markup specifier. ('{color: red}')

If `:filter_classes` is set, it will also disable class attributes. ('!(classname)image!')

If `:filter_ids` is set, it will also disable id attributes. ('!(classnameid)image!')

filter_html[RW]

Accessors for setting security restrictions.

This is a nice thing if you're using RedCloth for formatting in public places (e.g. Wikis) where you don't want users to abuse HTML for bad things.

If `:filter_html` is set, HTML which wasn't created by the Textile processor will be escaped. Alternatively, if `:sanitize_html` is set, HTML can pass through the Textile processor but unauthorized tags and attributes will be removed.

If `:filter_styles` is set, it will also disable the style markup specifier. ('{color: red}')

If `:filter_classes` is set, it will also disable class attributes. ('!(classname)image!')

If `:filter_ids` is set, it will also disable id attributes. ('!(classnameid)image!')

filter_ids[RW]

Accessors for setting security restrictions.

This is a nice thing if you're using RedCloth for formatting in public places (e.g. Wikis) where you don't want users to abuse HTML for bad things.

If `:filter_html` is set, HTML which wasn't created by the Textile processor will be escaped. Alternatively, if `:sanitize_html` is set, HTML can pass through the Textile processor but unauthorized tags and attributes will be removed.

If `:filter_styles` is set, it will also disable the style markup specifier. ('{color: red}')

If `:filter_classes` is set, it will also disable class attributes. ('!(classname)image!')

If `:filter_ids` is set, it will also disable id attributes. ('!(classnameid)image!')

filter_styles[RW]

Accessors for setting security restrictions.

This is a nice thing if you're using RedCloth for formatting in public places (e.g. Wikis) where you don't want users to abuse HTML for bad things.

If `:filter_html` is set, HTML which wasn't created by the Textile processor will be escaped. Alternatively, if `:sanitize_html` is set, HTML can pass through the Textile processor but unauthorized tags and attributes will be removed.

If `:filter_styles` is set, it will also disable the style markup specifier. ('{color: red}')

If `:filter_classes` is set, it will also disable class attributes. ('!(classname)image!')

If `:filter_ids` is set, it will also disable id attributes. ('!(classnameid)image!')

hard_breaks[RW]

Deprecated accessor for toggling hard breaks.

Traditional RedCloth converted single newlines to HTML break tags, but later versions required `:hard_breaks` be set to enable this behavior. `:hard_breaks` is once again the default.

lite_mode[RW]

Accessor for toggling lite mode.

In lite mode, block-level rules are ignored. This means that tables, paragraphs, lists, and such aren't available. Only the inline markup for bold, italics, entities and so on.

    r = RedCloth.new( "And then? She *fell*!", [:lite_mode] )
    r.to_html
    #=> "And then? She <strong>fell</strong>!"

no_span_caps[RW]

Accessor for toggling span caps.

Textile places `span' tags around capitalized words by default, but this wreaks havoc on Wikis. If `:no_span_caps` is set, this will be suppressed.

sanitize_html[RW]

Accessors for setting security restrictions.

This is a nice thing if you're using RedCloth for formatting in public places (e.g. Wikis) where you don't want users to abuse HTML for bad things.

If `:filter_html` is set, HTML which wasn't created by the Textile processor will be escaped. Alternatively, if `:sanitize_html` is set, HTML can pass through the Textile processor but unauthorized tags and attributes will be removed.

If `:filter_styles` is set, it will also disable the style markup specifier. ('{color: red}')

If `:filter_classes` is set, it will also disable class attributes. ('!(classname)image!')

If `:filter_ids` is set, it will also disable id attributes. ('!(classnameid)image!')

### Public Class Methods

new( string, restrictions = [] ) click to toggle source

Returns a new RedCloth object, based on string, observing any restrictions specified.

    r = RedCloth.new( "h1. A *bold* man" )
      #=> "h1. A *bold* man"
    r.to_html
      #=>"<h1>A <b>bold</b> man</h1>"

    # File lib/redcloth/textile_doc.rb, line 67
    def initialize( string, restrictions = [] )
      restrictions.each { |r| method("#{r}=").call( true ) }
      super( string )
    end

### Public Instance Methods

html_esc(*args) click to toggle source

Converts special characters into HTML entities.

    static VALUE
    redcloth_html_esc(int argc, VALUE* argv, VALUE self)

latex_esc(p1) click to toggle source

Converts special characters into LaTeX entities.

    static VALUE
    redcloth_latex_esc(VALUE self, VALUE str)
    {
      VALUE new_str = STR_NEW2("");

      if (str == Qnil)
        return new_str;

      StringValue(str);

      if (RSTRING_LEN(str) == 0)
        return new_str;

      char *ts = RSTRING_PTR(str), *te = RSTRING_PTR(str) + RSTRING_LEN(str);
      char *t = ts, *t2 = ts;
      const char *ch = NULL;
      if (te <= ts) return Qnil;

      while (t2 < te) {
        ch = NULL;

        switch (*t2)
        {
          case '{':  ch = "#123";   break;
          case '}':  ch = "#125";   break;
          case '\\': ch = "#92";    break;
          case '#':  ch = "#35";    break;
          case '$':  ch = "#36";    break;
          case '%':  ch = "#37";    break;
          case '&':  ch = "amp";    break;
          case '_':  ch = "#95";    break;
          case '^':  ch = "circ";   break;
          case '~':  ch = "tilde";  break;
          case '<':  ch = "lt";     break;
          case '>':  ch = "gt";     break;
          case '\n': ch = "#10";    break;
        }

        if (ch != NULL)
        {
          if (t2 > t)
            rb_str_cat(new_str, t, t2-t);
          VALUE opts = rb_hash_new();
          rb_hash_aset(opts, ID2SYM(rb_intern("text")), STR_NEW2(ch));
          rb_str_concat(new_str, rb_funcall(self, rb_intern("entity"), 1, opts));
          t = t2 + 1;
        }

        t2++;
      }
      if (t2 > t)
        rb_str_cat(new_str, t, t2-t);

      return new_str;
    }

to(p1) click to toggle source

Transforms a Textile document with `formatter`

    static VALUE
    redcloth_to(self, formatter)
      VALUE self, formatter;
    {
      rb_funcall(self, rb_intern("delete!"), 1, STR_NEW2("\r"));
      VALUE working_copy = rb_obj_clone(self);
      rb_extend_object(working_copy, formatter);

      if (rb_funcall(working_copy, rb_intern("lite_mode"), 0) == Qtrue) {
        return redcloth_inline2(working_copy, self, rb_hash_new());
      } else {
        return redcloth_transform2(working_copy, self);
      }
    }

to_html( *rules ) click to toggle source

Generates HTML from the Textile contents.

    RedCloth.new( "And then? She *fell*!" ).to_html
      #=>"<p>And then? She <strong>fell</strong>!</p>"

    # File lib/redcloth/textile_doc.rb, line 78
    def to_html( *rules )
      apply_rules(rules)

      to(RedCloth::Formatters::HTML)
    end

to_latex( *rules ) click to toggle source

Generates LaTeX from the Textile contents.

    RedCloth.new( "And then? She *fell*!" ).to_latex
      #=> "And then? She \\textbf{fell}!\n\n"

    # File lib/redcloth/textile_doc.rb, line 90
    def to_latex( *rules )
      apply_rules(rules)

      to(RedCloth::Formatters::LATEX)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.