Class | RedCloth |
In: |
lib/redcloth/textile.rb
lib/redcloth/docbook.rb lib/redcloth/markdown.rb lib/redcloth/base.rb |
Parent: | String |
TEXTILE_TAGS | = | [[128, 8364], [129, 0], [130, 8218], [131, 402], [132, 8222], [133, 8230], [134, 8224], [135, 8225], [136, 710], [137, 8240], [138, 352], [139, 8249], [140, 338], [141, 0], [142, 0], [143, 0], [144, 0], [145, 8216], [146, 8217], [147, 8220], [148, 8221], [149, 8226], [150, 8211], [151, 8212], [152, 732], [153, 8482], [154, 353], [155, 8250], [156, 339], [157, 0], [158, 0], [159, 376]]. collect! do |a, b| [a.chr, ( b.zero? and "" or "&##{ b };" )] | Mapping of 8-bit ASCII codes to HTML numerical entity equivalents. (from PyTextile) | |
DOCBOOK_GLYPHS | = | [ [ /([^\s\[{(>])\'/, '\1’' ], # single closing [ /\'(?=\s|s\b|[#{PUNCT}])/, '’' ], # single closing [ /\'/, '‘' ], # single opening # [ /([^\s\[{(])?"(\s|:|$)/, '\1”\2' ], # double closing [ /([^\s\[{(>])"/, '\1”' ], # double closing [ /"(?=\s|[#{PUNCT}])/, '”' ], # double closing [ /"/, '“' ], # double opening [ /\b( )?\.{3}/, '\1…' ], # ellipsis [ /(\.\s)?\s?--\s?/, '\1—' ], # em dash [ /\s->\s/, ' → ' ], # right arrow [ /\s-\s/, ' – ' ], # en dash [ /(\d+) ?x ?(\d+)/, '\1×\2' ], # dimension sign [ /\b ?[(\[]TM[\])]/i, '™' ], # trademark [ /\b ?[(\[]R[\])]/i, '®' ], # registered [ /\b ?[(\[]C[\])]/i, '©' ] | Elements to handle | |
SIMPLE_DOCBOOK_TAGS | = | [ 'para', 'title', 'remark', 'blockquote', 'itemizedlist', 'orderedlist', 'variablelist', 'programlisting', 'screen', 'literallayout', 'figure', 'example', 'abbrev', 'accel', 'acronym', 'action', 'application', 'citation', 'citetitle', 'classname', 'classref', 'command', 'computeroutput', 'email', 'emphasis', 'envar', 'filename', 'firstterm', 'foreignphrase', 'footnoteref', 'graphic', 'function', 'guibutton', 'guimenu', 'guimenuitem', 'keycap', 'keysym', 'lineannotation', 'literal', 'option', 'optional', 'parameter', 'prompt', 'quote', 'replaceable', 'returnvalue', 'sgmltag', 'structfield', 'structname', 'subscript', 'superscript', 'symbol', 'systemitem', 'type', 'userinput', 'wordasword', 'xref' |
Elements to handle
GLYPHS << [ /\b([A-Z][A-Z0-9]{2,})\b(?:[(]([^)]*)[)])/, '<acronym title="\2">\1</acronym>' ] # 3+ uppercase acronym GLYPHS << [ /(^|[^"][>\s])([A-Z][A-Z0-9 ]{2,})([^<a-z0-9]|$)/, '\1<span class="caps">\2</span>\3', :no_span_caps ] # 3+ uppercase caps |
|
DOCBOOK_TAGS | = | [ ['**', 'emphasis role="strong"'], ['__', 'emphasis'], ['*', 'emphasis role="strong"', :limit], ['_', 'emphasis', :limit], ['??', 'citation', :limit], ['^', 'superscript', :limit], ['~', 'subscript', :limit], ['%', 'para', :limit], ['@', 'literal', :limit], ] | ||
DOCBOOK_DIVS | = | ['note', 'blockquote', 'warning'] | ||
DOCBOOK_REFS_RE | = | /(^ *)\[([^\[\n]+?)\](#{HYPERLINK})(?=\s|$)/ | ||
DOCBOOK_OFFTAGS | = | /(nodocbook|programlisting)/i | ||
DOCBOOK_OFFTAG_MATCH | = | /(?:(<\/#{ DOCBOOK_OFFTAGS }>)|(<#{ DOCBOOK_OFFTAGS }[^>]*>))(.*?)(?=<\/?#{ DOCBOOK_OFFTAGS }|\Z)/mi | ||
DOCBOOK_OFFTAG_OPEN | = | /<#{ DOCBOOK_OFFTAGS }/ | ||
DOCBOOK_OFFTAG_CLOSE | = | /<\/?#{ DOCBOOK_OFFTAGS }/ | ||
I18N_HIGHER_CASE_LETTERS | = | "√Ä√?√Ç√É√Ñ√փăуÇ√Ü√áƒÜƒåƒàƒäƒéƒ?√à√â√ä√ãƒíƒòƒöƒîƒñƒúƒûƒ†ƒ¢ƒ§ƒ¶√å√?√é√?ƒ™ƒ®ƒ¨ƒÆƒ∞ƒ≤ƒ¥ƒ∂≈?ƒΩƒπƒªƒø√ë≈É≈á≈Ö≈ä√í√ì√î√ï√ñ√ò≈å≈?≈é≈í≈î≈ò≈ñ≈ö≈†≈û≈ú»ò≈§≈¢≈¶»ö√ô√ö√õ√ú≈™≈Æ≈∞≈¨≈®≈≤≈¥√?≈∂≈∏≈π≈Ω≈ª" + "ŒëŒíŒìŒîŒïŒñŒóŒòŒôŒöŒõŒúŒ?ŒûŒüŒ†Œ°Œ£Œ§Œ•Œ¶ŒßŒ®Œ©" + "ŒÜŒàŒâŒäŒåŒéŒ?—†—¢—§—¶—®—™—¨—Æ—∞—≤—¥—∂—∏—∫—º—æ“Ä“ä“å“é“?“í“î“ñ“ò“ö“ú“û“†“¢“§“¶“®“™“¨“Æ“∞“≤“¥“∂“∏“∫“º“æ”?”ɔ֔á”â”ã”?”?”í”î”ñ”ò”ö”ú”û”†”¢”§”¶”®”™”¨”Æ”∞”≤”¥”∏–ñ" + "‘±‘≤‘≥‘¥‘µ‘∂‘∑‘∏‘π‘∫‘ª‘º‘Ω‘æ‘ø’Ä’?’Ç’É’Ñ’Ö’Ü’á’à’â’ä’ã’å’?’?’?’ë’í’ì’î’ï’ñ" | In order of appearance: Latin, greek, cyrillian, armenian | |
I18N_LOWER_CASE_LETTERS | = | "√†√°√¢√£√§√•ƒ?ƒÖƒÉ√¶√߃áƒ?ƒâƒãƒ?ƒë√®√©√™√´ƒìƒôƒõƒïƒó∆íƒ?ƒüƒ°ƒ£ƒ•ƒß√¨√≠√Æ√؃´ƒ©ƒ≠ƒØƒ±ƒ≥ƒµƒ∑ƒ∏≈ǃæƒ∫ƒº≈Ä√±≈Ñ≈à≈Ü≈â≈ã√≤√≥√¥√µ√∂√∏≈?≈ë≈?≈ì≈ï≈ô≈ó≈õ≈°≈ü≈?»ô≈•≈£≈ß»õ√π√∫√ª√º≈´≈Ø≈±≈≠≈©≈≥≈µ√Ω√ø≈∑≈æ≈º≈∫√û√æ√ü≈ø√?√∞" + "Œ¨Œ≠ŒÆŒØŒ∞Œ±Œ≤Œ≥Œ¥ŒµŒ∂Œ∑Œ∏ŒπŒ∫ŒªŒºŒΩŒæŒøœÄœ?œÇœÉœÑœÖœÜœáœàœâœäœãœåœ?œéŒ?" + "–∞–±–≤–≥–¥–µ–∂–∑–∏–π–∫–ª–º–Ω–æ–ø—Ä—?—Ç—É—Ñ—Ö—Ü—á—à—â—ä—ã—å—?—é—?—?—ë—í—ì—î—ï—ñ—ó—ò—ô—õ—ú—?—û—ü—°—£—•—ß—©—´—≠—Ø—±—≥—µ—∑—π—ª—Ω—ø“?“ã“?“?“ë“ì“ï“ó“ô“õ“?“ü“°“£“•“ß“©“´“≠“Ø“±“≥“µ“∑“𓪓ٓø”Ĕǔєܔà”ä”å”é”ë”ì”ï”ó”ô”õ”?”ü”°”£”•”ß”©”´”≠”Ø”±”≥”µ”π" + "’°’¢’£’§’•’¶’ß’®’©’™’´’¨’≠’Æ’Ø’∞’±’≤’≥’¥’µ’∂’∑’∏’π’∫’ª’º’Ω’æ’ø÷Ä÷?÷Ç÷É÷Ñ÷Ö÷Ü÷á" | ||
WIKI_WORD_PATTERN | = | '[A-Z' + I18N_HIGHER_CASE_LETTERS + '][a-z' + I18N_LOWER_CASE_LETTERS + ']+[A-Z' + I18N_HIGHER_CASE_LETTERS + ']\w+' | ||
CAMEL_CASED_WORD_BORDER | = | /([a-z#{I18N_LOWER_CASE_LETTERS}])([A-Z#{I18N_HIGHER_CASE_LETTERS}])/u | ||
WIKI_WORD | = | Regexp.new('(":)?(\\\\)?(' + WIKI_WORD_PATTERN + ')\b', 0, "utf-8") | ||
WIKI_LINK | = | /(":)?\[\[([^\]]+)\]\]/ | ||
DOCBOOK_PARAS | = | ['para', 'remark', 'tip', 'important'] | ||
MARKDOWN_BQ_RE | = | /\A(^ *> ?.+$(.+\n)*\n*)+/m | ||
MARKDOWN_RULE_RE | = | /^(.*)( ?[#{ ['*', '-', '_'].collect { |ch| Regexp::quote( ch ) }.join }] ?){3,}(.*)$/ | ||
MARKDOWN_REFLINK_RE | = | / \[([^\[\]]+)\] # $text [ ]? # opt. space (?:\n[ ]*)? # one optional newline followed by spaces \[(.*?)\] # $id /x | ||
MARKDOWN_LINK_RE | = | / \[([^\[\]]+)\] # $text \( # open paren [ \t]* # opt space <?(.+?)>? # $href [ \t]* # opt space (?: # whole title (['"]) # $quote (.*?) # $title \3 # matching quote )? # title is optional \) /x | ||
MARKDOWN_REFS_RE | = | /(^ *)\[([^\n]+?)\]:\s+<?(#{HYPERLINK})>?(?:\s+"((?:[^"]|\\")+)")?(?=\s|$)/m | ||
VERSION | = | '3.0.99.0.svn.20060519' | ||
DEFAULT_RULES | = | [] | ||
TEXTILE_RULES | = | [:refs_textile, :block_textile_table, :block_textile_lists, :block_textile_defs, :block_textile_prefix, :inline_textile_image, :inline_textile_link, :inline_textile_code, :inline_textile_span, :glyphs_textile, :inline_textile_autolink_urls, :inline_textile_autolink_emails] | ||
MARKDOWN_RULES | = | [:refs_markdown, :block_markdown_setext, :block_markdown_atx, :block_markdown_rule, :block_markdown_bq, :block_markdown_lists, :inline_markdown_reflink, :inline_markdown_link] | ||
DOCBOOK_RULES | = | [:refs_docbook, :block_docbook_table, :block_docbook_lists, :block_docbook_simple_lists, :block_docbook_defs, :block_docbook_prefix, :inline_docbook_image, :inline_docbook_link, :inline_docbook_code, :inline_docbook_glyphs, :inline_docbook_span, :inline_docbook_wiki_words, :inline_docbook_wiki_links, :inline_docbook_autolink_urls, :inline_docbook_autolink_emails] | ||
LB | = | "0docbook0line0break0" | Regular expressions to convert to HTML. | |
NB | = | "0docbook0no0break0\n\n" | ||
A_HLGN | = | /(?:(?:<>|<|>|\=|[()]+)+)/ | ||
A_VLGN | = | /[\-^~]/ | ||
C_CLAS | = | '(?:\([^)]+\))' | ||
C_LNGE | = | '(?:\[[^\]]+\])' | ||
C_STYL | = | '(?:\{[^}]+\})' | ||
S_CSPN | = | '(?:\\\\\d+)' | ||
S_RSPN | = | '(?:/\d+)' | ||
A | = | "(?:#{A_HLGN}?#{A_VLGN}?|#{A_VLGN}?#{A_HLGN}?)" | ||
S | = | "(?:#{S_CSPN}?#{S_RSPN}|#{S_RSPN}?#{S_CSPN}?)" | ||
C | = | "(?:#{C_CLAS}?#{C_STYL}?#{C_LNGE}?|#{C_STYL}?#{C_LNGE}?#{C_CLAS}?|#{C_LNGE}?#{C_STYL}?#{C_CLAS}?)" | ||
PUNCT | = | Regexp::quote( '!"#$%&\'*+,-./:;=?@\\^_`|~' ) | ||
PUNCT_NOQ | = | Regexp::quote( '!"#$&\',./:;=?@\\`|' ) | ||
PUNCT_Q | = | Regexp::quote( '*-_+^~%' ) | ||
HYPERLINK | = | '(\S+?)([^\w\s/;=\?]*?)(?=\s|<|$)' | ||
TABLE_RE | = | /^(?:caption ?\{(.*?)\}\. ?\n)?^(?:id ?\{(.*?)\}\. ?\n)?^(?:table(_?#{S}#{A}#{C})\. ?\n)?^(#{A}#{C}\.? ?\|.*?\|)(\n\n|\Z)/m | ||
LISTS_RE | = | /^([#*_0-9]+?#{C} .*?)$(?![^#*])/m | ||
LISTS_CONTENT_RE | = | /^([#*]+)([_0-9]*)(#{A}#{C}) (.*)$/m | ||
DEFS_RE | = | /^(-#{C}\s.*?\:\=.*?)$(?![^-])/m | ||
DEFS_CONTENT_RE | = | /^(-)(#{A}#{C})\s+(.*?):=(.*)$/m | ||
BACKTICK_CODE_RE | = | /(.*?) ``` (?:\|(\w+?)\|)? (.*?[^\\]) ``` (.*?)/mx | ||
CODE_RE | = | /(.*?) @@? (?:\|(\w+?)\|)? (.*?[^\\]) @@? (.*?)/x | ||
BLOCKS_GROUP_RE | = | /\n{2,}(?! )/m | ||
BLOCK_RE | = | /^(([a-z]+)(\d*))(#{A}#{C})\.(?::(\S+))? (.*)$/ | ||
SETEXT_RE | = | /\A(.+?)\n([=-])[=-]* *$/m | ||
ATX_RE | = | /\A(\#{1,6}) # $1 = string of #'s [ ]* (.+?) # $2 = Header text [ ]* \#* # optional closing #'s (not counted) $/x | ||
LINK_RE | = | / ([\s\[{(]|[#{PUNCT}])? # $pre " # start (#{C}) # $atts ([^"]+?) # $text \s? (?:\(([^)]+?)\)(?="))? # $title ": ([^\s<]+?) # $url (\/)? # $slash ([^\w\/;]*?) # $post (?=<|\s|$) /x | ||
IMAGE_RE | = | / (<p>|.|^) # start of line? \! # opening (\<|\=|\>)? # optional alignment atts (#{C}) # optional style,class atts (?:\. )? # optional dot-space ([^\s(!]+?) # presume this is the src \s? # optional space (?:\(((?:[^\(\)]|\([^\)]+\))+?)\))? # optional title \! # closing (?::#{ HYPERLINK })? # optional href /x | ||
SIMPLE_HTML_TAGS | = | [ 'tt', 'b', 'i', 'big', 'small', 'em', 'strong', 'dfn', 'code', 'samp', 'kbd', 'var', 'cite', 'abbr', 'acronym', 'a', 'img', 'br', 'br', 'map', 'q', 'sub', 'sup', 'span', 'bdo' | Text markup tags, don’t conflict with block tags | |
QTAGS | = | [ ['**', 'b'], ['*', 'strong'], ['??', 'cite', :limit], ['-', 'del', :limit], ['__', 'i'], ['_', 'em', :limit], ['%', 'span', :limit], ['+', 'ins', :limit], ['^', 'sup'], ['~', 'sub'] | ||
GLYPHS | = | [ # [ /([^\s\[{(>])?\'([dmst]\b|ll\b|ve\b|\s|:|$)/, '\1’\2' ], # single closing [ /([^\s\[{(>#{PUNCT_Q}][#{PUNCT_Q}]*)\'/, '\1’' ], # single closing [ /\'(?=[#{PUNCT_Q}]*(s\b|[\s#{PUNCT_NOQ}]))/, '’' ], # single closing [ /\'/, '‘' ], # single opening # [ /([^\s\[{(])?"(\s|:|$)/, '\1”\2' ], # double closing [ /([^\s\[{(>#{PUNCT_Q}][#{PUNCT_Q}]*)"/, '\1”' ], # double closing [ /"(?=[#{PUNCT_Q}]*[\s#{PUNCT_NOQ}])/, '”' ], # double closing [ /"/, '“' ], # double opening [ /\b( )?\.{3}/, '\1…' ], # ellipsis [ /\b([A-Z][A-Z0-9]{2,})\b(?:[(]([^)]*)[)])/, '<acronym title="\2">\1</acronym>' ], # 3+ uppercase acronym [ /(^|[^"][>\s])([A-Z][A-Z0-9 ]+[A-Z0-9])([^<A-Za-z0-9]|$)/, '\1<span class="caps">\2</span>\3', :no_span_caps ], # 3+ uppercase caps [ /(\.\s)?\s?--\s?/, '\1—' ], # em dash [ /(^|\s)->(\s|$)/, ' → ' ], # right arrow [ /(^|\s)-(\s|$)/, ' – ' ], # en dash [ /(\d+) x (\d+)/, '\1×\2' ], # dimension sign [ /\b ?[(\[]TM[\])]/i, '™' ], # trademark [ /\b ?[(\[]R[\])]/i, '®' ], # registered [ /\b ?[(\[]C[\])]/i, '©' ] | Elements to handle | |
H_ALGN_VALS | = | { '<' => 'left', '=' => 'center', '>' => 'right', '<>' => 'justify' | ||
V_ALGN_VALS | = | { '^' => 'top', '-' => 'middle', '~' => 'bottom' | ||
OFFTAGS | = | /(code|pre|kbd|notextile)/i | ||
OFFTAG_MATCH | = | /(?:(<\/#{ OFFTAGS }>)|(<#{ OFFTAGS }[^>]*>))(.*?)(?=<\/?#{ OFFTAGS }|\Z)/mi | ||
OFFTAG_OPEN | = | /<#{ OFFTAGS }/ | ||
OFFTAG_CLOSE | = | /<\/?#{ OFFTAGS }/ | ||
HASTAG_MATCH | = | /(<\/?\w[^\n]*?>)/m | ||
ALLTAG_MATCH | = | /(<\/?\w[^\n]*?>)|.*?(?=<\/?\w[^\n]*?>|$)/m | ||
BLOCK_GROUP_SPLITTER | = | "XXX_BLOCK_GROUP_XXX\n\n" | ||
BASIC_TAGS | = | { 'a' => ['href', 'title'], 'img' => ['src', 'alt', 'title'], 'br' => [], 'i' => nil, 'u' => nil, 'b' => nil, 'pre' => nil, 'kbd' => nil, 'code' => ['lang'], 'cite' => nil, 'strong' => nil, 'em' => nil, 'ins' => nil, 'sup' => nil, 'sub' => nil, 'del' => nil, 'table' => nil, 'tr' => nil, 'td' => ['colspan', 'rowspan'], 'th' => nil, 'ol' => ['start'], 'ul' => nil, 'li' => nil, 'p' => nil, 'h1' => nil, 'h2' => nil, 'h3' => nil, 'h4' => nil, 'h5' => nil, 'h6' => nil, 'blockquote' => ['cite'] | HTML cleansing stuff | |
AUTO_LINK_RE | = | / ( # leading text <\w+.*?>| # leading HTML tag, or [^=!:'"\/]| # leading punctuation, or ^ # beginning of line ) ( (?:http[s]?:\/\/)| # protocol spec, or (?:www\.) # www.* ) ( ([\w]+[=?&:%\/\.\~\-]*)* # url segment \w+[\/]? # url tail (?:\#\w*)? # trailing anchor ) ([[:punct:]]|\s|<|$) # trailing text /x |
filter_classes | [RW] |
Two accessor 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. 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] |
Two accessor 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. 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] |
Two accessor 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. 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] |
Two accessor 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. 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] |
Accessor for toggling hard breaks.
If +:hard_breaks+ is set, single newlines will be converted to HTML break tags. This is the default behavior for traditional RedCloth. |
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. |
rules | [RW] | Establishes the markup predence. |
Returns a new RedCloth object, based on string and enforcing all the included restrictions.
r = RedCloth.new( "h1. A <b>bold</b> man", [:filter_html] ) r.to_html #=>"<h1>A <b>bold</b> man</h1>"
# File lib/redcloth/base.rb, line 83 83: def initialize( string, restrictions = [] ) 84: restrictions.each { |r| method( "#{ r }=" ).call( true ) } 85: super( string ) 86: end
Generates HTML from the Textile contents.
r = RedCloth.new( "And then? She *fell*!" ) r.to_docbook #=>"And then? She <emphasis role=\"strong\">fell</emphasis>!"
# File lib/redcloth/docbook.rb, line 55 55: def to_docbook( *rules ) 56: @stack = Array.new 57: @ids = Array.new 58: @references = Array.new 59: @automatic_content_ids = Array.new 60: 61: rules = DEFAULT_RULES if rules.empty? 62: # make our working copy 63: text = self.dup 64: 65: @urlrefs = {} 66: @shelf = [] 67: @rules = rules.collect do |rule| 68: case rule 69: when :docbook 70: DOCBOOK_RULES 71: else 72: rule 73: end 74: end.flatten 75: 76: # standard clean up 77: incoming_entities text 78: clean_white_space text 79: 80: # start processor 81: @pre_list = [] 82: pre_process_docbook text 83: 84: no_docbook text 85: docbook_rip_offtags text 86: docbook_hard_break text 87: 88: refs text 89: docbook_blocks text 90: inline text 91: 92: smooth_offtags text 93: retrieve text 94: 95: post_process_docbook text 96: clean_html text if filter_html 97: text.strip! 98: 99: text << "\n" 100: @stack.each_with_index {|sect,index| text << "</sect#{@stack.size-index}>\n"} 101: text << "</chapter>" if @chapter 102: 103: if (@references - @ids).size > 0 104: text << %{<chapter label="86" id="chapter-86"><title>To Come</title>} 105: (@references - @ids).each {|name| text << %!<sect1 id="#{name}"><title>#{name.split('-').map {|t| t.capitalize}.join(' ')}</title><remark>TK</remark></sect1>\n!} 106: text << "</chapter>" 107: end 108: 109: text 110: 111: end
Generates HTML from the Textile contents.
r = RedCloth.new( "And then? She *fell*!" ) r.to_html( true ) #=>"And then? She <strong>fell</strong>!"
# File lib/redcloth/base.rb, line 95 95: def to_html( *rules ) 96: rules = DEFAULT_RULES if rules.empty? 97: # make our working copy 98: text = self.dup 99: 100: return "" if text == "" 101: 102: @urlrefs = {} 103: @shelf = [] 104: @rules = rules.collect do |rule| 105: case rule 106: when :markdown 107: MARKDOWN_RULES 108: when :textile 109: TEXTILE_RULES 110: else 111: rule 112: end 113: end.flatten 114: 115: # standard clean up 116: @pre_list = [] 117: pre_process text 118: DEFAULT_RULES.each {|ruleset| send("#{ruleset}_pre_process", text) if private_methods.include? "#{ruleset}_pre_process"} 119: incoming_entities text 120: clean_white_space text 121: 122: # start processor 123: no_textile text 124: rip_offtags text 125: hard_break text 126: unless @lite_mode 127: refs text 128: blocks text 129: end 130: inline text 131: smooth_offtags text 132: retrieve text 133: 134: post_process text 135: DEFAULT_RULES.each {|ruleset| send("#{ruleset}_post_process", text) if private_methods.include? "#{ruleset}_post_process"} 136: 137: clean_html text if filter_html 138: 139: return text.strip 140: 141: end