Sha256: f51fba282776efdbbb0a91a9da6312c9a6ab2d4d1a9fdb59d0464b37d32b5b5f
Contents?: true
Size: 1.81 KB
Versions: 3
Compression:
Stored size: 1.81 KB
Contents
== Markdown Malt supports Markdown via either the RDiscount, BlueCloth or Kramdown backends. Lets say we have a Markdown document called 'test.md' containing ... # Example This is an example of Markdown rendering. Markdown documents are recognized by the +.markdown+ or +.md+ file extensions. html = Malt.render(:file=>'tmp/test.md') html.assert.include?('<h1>Example</h1>') By default teh RDiscount library is used to render markdown documents, but Malt supports BlueCloth and Kramdown as well. These case be used by setting the :engine option. html = Malt.render(:file=>'tmp/test.md', :engine=>:bluecloth) And as we can see the document rendered as expected. html.assert.include?('<h1>Example</h1>') And using the Kramdown library, html = Malt.render(:file=>'tmp/test.md', :engine=>:kramdown) We can see the document rendered as well, though notice that Kramdown provides some bonus features compared to the other rendering engines. html.assert.include?('<h1 id="example">Example</h1>') Malt supports Markdown via either the RDiscount, BlueCloth or Kramdown backends. Lets say we have an Markdown document called 'test.md' containing ... # Example This is an example of Markdown rendering. We can access the file via the +Malt.file+ method. Markdown documents are recognized by the +.markdown+ or +.md+ file extensions. mark = Malt.file('tmp/test.md') We can the convert the document to a Malt Html object via the #to_html method. html = mark.to_html Notice that the output is an instance of Malt::Format::HTML. html.class.assert == Malt::Format::HTML And that by calling #to_s we can get the rendered HTML document. html.to_s.assert.include?('<h1>Example</h1>') Or we can convert the document directly to HTML via the #html method. out = mark.html out.assert.include?('<h1>Example</h1>')
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
malt-0.3.0 | qed/03_formats/04_markdown.rdoc |
malt-0.2.0 | qed/03_formats/04_markdown.rdoc |
malt-0.1.1 | qed/03_formats/04_markdown.rdoc |