LinkResolver Class

Defined in: lib/HTMLSerializer__LinkResolver.js

Public Functions

Stringlookup()
Stringlinkify(String)
StringrenderLink(Object, Object)

Constructor Documentation

LinkResolver(corpus: Corpus)

Parameters (1)

corpus
Corpus

The corpus of documents.

Instance Method Documentation

    linkify(docstring: String) -> String

    Linkify all internal links found in a block of text.

    Parameters (1)

    docstring
    String

    The block of text possibly containing internal links.

    Return Value

    String

    The text with all the internal links that were successfully resolved replaced with markdown-formatted links.

    Example

    LinkResolver.linkify('See [Module]() for more info.');
    // => "See [ModuleTitle](/internal/path/to/module) for more info."

    lookup() -> Object

    Look up an item and generate a URL to it, if found.

    Parameters (2)

    params.path
    String

    The index path.

    params.contextNode
    T.Node

    The node we're resolving from.

    Return Values

    link
    Object
    link.href
    String
    link.title
    String

    renderLink(params: Object, descriptor: Object) -> StringPRIVATE

    Parameters (9)

    params
    Object
    params.contextNode
    T.Node
    params.strict
    Boolean

    Will warn when enabled and the link could not be resolved.

    Defaults to: true

    params.format
    String

    One of "html" or "markdown".

    descriptor
    Object
    descriptor.source
    String

    The source string that generated this link. This must be present so that we can use it if the link could not be resolved, in which case we'll use it as a text for a "broken" anchor that will be highlighted in the UI.

    descriptor.path
    String

    The index path to resolve.

    descriptor.text
    String

    Will be used as the anchor's text. If not specified, we'll use the document's title in its place.

    descriptor.title
    String

    Will be used as the anchor's [title] attribute (a tooltip). If not specified, we'll use the document's summary in its place.

    Return Value

    String