lib/erbook/to_xhtml.rb
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
##
# Transforms this string into XHTML.
#
Transforms this string into XHTML.
Transforms this string into XHTML .
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
      while html.gsub! %r{(<pre>)<code>(.*?)</code>(</pre>)}m, '\1\2\3'
      end
      while html.gsub! %r{<pre[^>]+>(<code[^>]+>.*?</code>)</pre>}m, '\1'
      end
      html.gsub! %r{(<pre>)[ \t]*\r?\n|\r?\n[ \t]*(</pre>)}, '\1\2'
      html.gsub! %r/<table\b/, '\& border="1"'
      html.thru_coderay
    end
  end
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 while html . gsub! %r{ (<pre>)<code>(.*?)</code>(</pre>) }m , '\1\2\3' end while html . gsub! %r{ <pre[^>]+>(<code[^>]+>.*?</code>)</pre> }m , '\1' end html . gsub! %r{ (<pre>)[  \t ]* \r ? \n | \r ? \n [  \t ]*(</pre>) } , '\1\2' html . gsub! %r/ <table \b / , '\& border="1"' html . thru_coderay end end
Transforms this string into XHTML.
Transforms this string into XHTML .
# Markdown's "code spans" should really be "pre spans" # allow "code spans" annotated with Maruku's IAL (Inline # Attribute List) Markdown extension to be syntax colored # allow user to type <pre> blocks on single lines # without affecting the display of their content # ensure tables have a border: this *greatly* improves # readability in text-based web browsers like w3m and lynx # add syntax coloring