commonmark-wikiwords

    3.1.0 • Public • Published

    WikiWords for commonmark.js CircleCIcodecov

    This package offers an AST transformer for adding WikiWords syntax to CommonMark.

    Usage

    var commonmark = require("commonmark");
    var wikiwords = require("commonmark-wikiwords");
     
    var reader = new commonmark.Parser();
    var writer = new commonmark.HtmlRenderer();
     
    var parsed = reader.parse(src);
    var transformed = wikiwords.transform(parsed);
     
    var htmlSrc = writer.render(transformed);

    WikiWord Syntax

    This package has a looser definition of WikiWords.

    In addition to FooBar and FooBarBaz, it supports FooBBar and FooB.

    This follow the exact definition of WikiCase on C2 Wiki, which does not allow these. If strict compliance is useful, please file a bug.

    To avoid forming wikiwords, C2 suggests embedding an empty string. You can do something similar in commonmark: Foo<!-- -->Bar.

    Highlighting Nonexistent Links

    You can also pass a callback to style links based on their name. This is useful for styling links that don't yet exist.

    var commonmark = require("commonmark");
    var wikiwords = require("commonmark-wikiwords");
     
    var reader = new commonmark.Parser();
    var writer = new commonmark.HtmlRenderer();
     
    var parsed = reader.parse(src);
    var transformed = wikiwords.transform(parsed, name =>
      name === "foo" ? "exciting-page" : null
    );
     
    var htmlSrc = writer.render(transformed);

    Install

    npm i commonmark-wikiwords

    DownloadsWeekly Downloads

    9

    Version

    3.1.0

    License

    ISC

    Unpacked Size

    12.3 kB

    Total Files

    7

    Last publish

    Collaborators

    • wilfredh