Renderer Class

Defined in: lib/Renderer.js

Markdown to HTML renderer.

Public Functions

String|ObjectrenderMarkdown(String, Object)
voidaddCodeBlockRenderer(String, Function)

Constructor Documentation

Renderer(config: Object)

Parameters (2)

config
Object
config.layoutOptions.singlePageMode
Boolean

Instance Method Documentation

    addCodeBlockRenderer(language: String, handler: Function)

    Install a handler for a certain language code-block. The handler is expected to return VALID, FULL HTML.

    Parameters (2)

    language
    String

    The language the renderer is expecting to handle.

    handler
    Function

    The rendering routine.

    Example: Installing a handler for a custom "dot" language:

    Renderer.addCodeBlockRenderer("dot", function(code) {
      return '<pre>' + code + '</pre>';
    });

    renderMarkdown(text: String, options: Object) -> String|Object

    Render Markdown to HTML.

    Parameters (5)

    text
    String

    Markdown text.

    options
    Object
    options.baseURL
    String

    The url to prefix the anchor links with. This is necessary only in the Single Page Mode because all anchors must be absolute then. In the regular mode, the anchors are shortened to be more friendly since they assume there won't be conflicts (because each "page" is expected to represent a single document.)

    Pass the documentNode's @meta.href value here if you're compiling from a corpus node.

    Defaults to: null

    options.anchorableHeadings
    Boolean

    Turn this off if you do not want the headings to have anchors - the [name] attribute and the .anchorable-heading stuff.

    Defaults to: true

    options.withTOC
    Boolean

    Turn this on if you want the ToC meta-data. The return value will be an object of the shape: { html: String, toc: Array.<Object> }.

    Defaults to: false

    Return Value

    String|Object

    The HTML.