Search results

There are no results.

markdown.html.Generator

class pub Generator

Generates 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: Bool

If footnotes should be included in the generated document.

This option defaults to true.

Static methods

new

Show source code
Hide source code
fn pub static new(document: ref Document) -> Generator {
  let footnotes = document.footnotes.iter.reduce(Map.new, fn (map, entry) {
    map.set(entry.key, map.size + 1)
    map
  })

  Generator(document: document, footnotes: footnotes, enable_footnotes: true)
}
fn pub static new(document: ref Document) -> Generator

Returns a new generator that will convert the given document to HTML.

Instance methods

generate

Show source code
Hide 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 -> Document

Generates the HTML document.