| Class | RedCloth::TextileDoc |
| In: |
lib/redcloth/textile_doc.rb
ext/redcloth_scan/redcloth_scan.c lib/redcloth/textile_doc.rb |
| Parent: | String |
A Textile document that can be converted to other formats. See the README for Textile syntax.
| 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. (’!(classname#id)image!’) |
| 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. (’!(classname#id)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. (’!(classname#id)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. (’!(classname#id)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. (’!(classname#id)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. (’!(classname#id)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. (’!(classname#id)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. (’!(classname#id)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. The accessor is deprecated and will be removed in a future version. |
| 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. The accessor is deprecated and will be removed in a future version. |
| 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>!" |
| 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. |
| 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. (’!(classname#id)image!’) |
| 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. (’!(classname#id)image!’) |
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 69
69: def initialize( string, restrictions = [] )
70: restrictions.each { |r| method("#{r}=").call( true ) }
71: super( string )
72: end
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 69
69: def initialize( string, restrictions = [] )
70: restrictions.each { |r| method("#{r}=").call( true ) }
71: super( string )
72: end
Converts special characters into HTML entities.
/*
* Converts special characters into HTML entities.
*/
static VALUE
redcloth_html_esc(int argc, VALUE* argv, VALUE self) //(self, str, level)
{
VALUE str, level;
rb_scan_args(argc, argv, "11", &str, &level);
VALUE new_str = rb_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, *ch = NULL;
if (te <= ts) return;
while (t2 < te) {
ch = NULL;
// normal + pre
switch (*t2)
{
case '&': ch = "amp"; break;
case '>': ch = "gt"; break;
case '<': ch = "lt"; break;
}
// normal (non-pre)
if (level != SYM_escape_preformatted) {
switch (*t2)
{
case '\n': ch = "br"; break;
case '"' : ch = "quot"; break;
case '\'':
ch = (level == SYM_escape_attributes) ? "apos" : "squot";
break;
}
}
if (ch != NULL)
{
if (t2 > t)
rb_str_cat(new_str, t, t2-t);
rb_str_concat(new_str, rb_funcall(self, rb_intern(ch), 1, rb_hash_new()));
t = t2 + 1;
}
t2++;
}
if (t2 > t)
rb_str_cat(new_str, t, t2-t);
return new_str;
}
Converts special characters into LaTeX entities.
/*
* Converts special characters into LaTeX entities.
*/
static VALUE
redcloth_latex_esc(VALUE self, VALUE str)
{
VALUE new_str = rb_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, *ch = NULL;
if (te <= ts) return;
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")), rb_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;
}
Transforms a Textile document with formatter
/*
* Transforms a Textile document with +formatter+
*/
static VALUE
redcloth_to(self, formatter)
VALUE self, formatter;
{
char *pe, *p;
int len = 0;
rb_funcall(self, rb_intern("delete!"), 1, rb_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);
}
}
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 80
80: def to_html( *rules )
81: apply_rules(rules)
82:
83: to(RedCloth::Formatters::HTML)
84: end
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 80
80: def to_html( *rules )
81: apply_rules(rules)
82:
83: to(RedCloth::Formatters::HTML)
84: end
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 92
92: def to_latex( *rules )
93: apply_rules(rules)
94:
95: to(RedCloth::Formatters::LATEX)
96: end