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
to_inline_xhtml()

Transforms this string into an inline XHTML string (one that does not contain any block-level XHTML elements at the root).

# File lib/erbook/to_xhtml.rb, line 46
  def to_inline_xhtml
    to_xhtml true
  end
to_xhtml(inline = false)

Transforms this string into XHTML while ensuring that the result contains one or more block-level elements at the root.

inline
If true, the resulting XHTML will not contain a block-level element at the root.
# File lib/erbook/to_xhtml.rb, line 58
  def to_xhtml inline = false
    with_protected_tags(self, VERBATIM_TAGS, true) do |text|
      html = with_protected_tags(text, PROTECTED_TAGS, false) do
        |s| s.thru_maruku inline
      end

      # Markdown's "code spans" should really be "pre spans"
      while html.gsub! %r{(<pre>)<code>(.*?)</code>(</pre>)}m, '\1\2\3'
      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