Method: JsDuck::Format::Doc#format
- Defined in:
- lib/jsduck/format/doc.rb
#format(input) ⇒ Object
Formats doc-comment for placement into HTML. Renders it with Markdown-formatter and replaces @link-s.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/jsduck/format/doc.rb', line 71 def format(input) # In ExtJS source "<pre>" is often at the end of paragraph, not # on its own line. But in that case RDiscount doesn't recognize # it as the beginning of <pre>-block and goes on parsing it as # normal Markdown, which often causes nested <pre>-blocks. # # To prevent this, we always add extra newline before <pre>. input.gsub!(/([^\n])<pre>((<code>)?$)/, "\\1\n<pre>\\2") # But we remove trailing newline after <pre> to prevent # code-blocks beginning with empty line. input.gsub!(/<pre>(<code>)?\n?/, "<pre>\\1") replace(RDiscount.new(input).to_html) end |