Methods
- T
Constants
PROTECTED_TAGS | = | { :pre => :block, # tag => is it a block or inline element? :code => :inline, :tt => :inline } |
The content of these XHTML tags will be preserved while they are being processed by Textile. By doing this, we avoid unwanted Textile transformations, such as quotation marks becoming curly (&8192;), in source code. |
||
VERBATIM_TAGS | = | { :noformat => :block # tag => is it a block or inline element? } |
The content of these XHTML tags will be preserved verbatim throughout the text-to-XHTML conversion process. |
Instance Public methods
Transforms this string into XHTML.
# File lib/erbook/to_xhtml.rb, line 49 def to_xhtml with_protected_tags(self, VERBATIM_TAGS, true) do |text| html = with_protected_tags(text, PROTECTED_TAGS, false) do |s| s.thru_maruku end # Markdown's "code spans" should really be "pre spans" while html.gsub! %r{(<pre>)<code>(.*?)</code>(</pre>)}m, '\1\2\3' end # allow "code spans" annotated with Maruku's IAL (Inline # Attribute List) Markdown extension to be syntax colored while html.gsub! %r{<pre[^>]+>(<code[^>]+>.*?</code>)</pre>}m, '\1' end # allow user to type <pre> blocks on single lines # without affecting the display of their content html.gsub! %r{(<pre>)[ \t]*\r?\n|\r?\n[ \t]*(</pre>)}, '\1\2' # ensure tables have a border: this *greatly* improves # readability in text-based web browsers like w3m and lynx html.gsub! %r/<table\b/, '\& border="1"' # add syntax coloring html.thru_coderay end end