Module: Codnar::Markdown

Defined in:
lib/codnar/markdown.rb

Overview

Convert Markdown to HTML.

Class Method Summary collapse

Class Method Details

.to_html(markdown) ⇒ Object

Process a Markdown String and return the resulting HTML. In addition to the normal Markdown syntax, processing supports the following Codnar-specific extensions:

  • The notation “[[chunk|template]]” is expanded to embedding the specified chunk (name) using the specified template at Weave time.

  • The notation “[[#name]]” defines an empty anchor. The HTML anchor id is not the specified name, but rather the identifier generated from it (in the same way that chunk names are converted to identifiers).

  • The notation “[…](#name)” defines a link to an anchor, which is either the chunk with the specified name, or an empty anchor defined as above.



17
18
19
20
21
22
23
# File 'lib/codnar/markdown.rb', line 17

def self.to_html(markdown)
  markdown = embed_chunks(markdown)
  markdown = id_anchors(markdown)
  html = RDiscount.new(markdown).to_html
  html = id_links(html)
  return html.clean_markup_html
end