markdown.html.Generator
type pub GeneratorGenerates an HTML document from a markup document.
Examples
import markdown.html (Generator)
import markdown.parser (Parser)
let doc = Parser.new('*hello*').parse.expect('the markup is invalid')
Generator.new(doc).generate.to_string # => "<p><strong>hello</strong></p>"
Fields
enable_footnotes
let pub @enable_footnotes: BoolIf footnotes should be included in the generated document.
This option defaults to true.
Static methods
new
Show source codeHide source code
fn pub static new(document: ref Document) -> Generator {
let footnotes = document.footnotes.iter.reduce(Map.new, fn (map, kv) {
map.set(kv.0, map.size + 1)
map
})
Generator(document: document, footnotes: footnotes, enable_footnotes: true)
}fn pub static new(document: ref Document) -> GeneratorReturns a new generator that will convert the given document to HTML.
Instance methods
generate
Show source codeHide source code
fn pub move generate -> html.Document {
let doc = html.Document.fragment
visit(@document.children, doc)
if @footnotes.size > 0 and @enable_footnotes { add_footnotes(doc) }
doc
}fn pub move generate -> DocumentGenerates the HTML document.