Version: v0.7.1 - Beta.  We welcome contributors & feedback.


Litemark.parse($text, $options = {}) -> HtmlString


Parse a string with Litemark content and return an HTML TypeString.


Option Value Description
features string Pipe-separated list of features or “:featureSet”
customTags map Map of custom square tags.
urlHandler function A callback function to process URLs.
Litemark.parse($text, {
    features: 'text|lists|headings'

// Using a :featureSet to activate a group of features
Litemark.parse($text, {
    features: ':forum'

Activating Features

This is a list of all feature flags, and corresponding :featureSets.

            :comment  :forum  :blog/:wiki  :xDangerAll

text            x        x         x            x
lists                    x         x            x
headings                 x         x            x
blocks                   x         x            x

images                   x         x            x
links                    x         x            x

tables                             x            x
inline                             x            x
callouts                           x            x
icons                              x            x
toc                                x            x

indexLinks                                      x
xDangerHtml                                     x

Feature Flags

Critical Feature Flags

URL Handler 

By default, Litemark will auto-hyperlink the most common URL patterns.

To override this behavior, provide a callback that takes a URL object and returns an HTML string.

Litemark.parse($text, {
    urlHandler: fn ($url) {
        $tag = html'<a href="{}">external link</a>'
        return $tag.fill($url)

Custom Square Tags 

You can create your own square tags via the customTags field.

Command names must:

The value can be:

$text = '''

    Here is a [squiggle].

    The truth is, [spoiler | the butler did it]

    Created by [user | Thrifty33]


Litemark.parse($text, {

    customTags: {

        squiggle0: html'~^~^~^~^~',

        spoiler1: html'<span class="spoiler">{1}</span>',

        // Link to user (e.g. /user/thrifty33)
        user1: fn ($name) {

            $nameSlug = $name.slug()
            $link = html'<a href="/user/{}">{}</>'

            return $link.fill($nameSlug, $name)

Custom Tags in Templates

To register custom tags for use in Litemark templates, add a litemarkCustomTags field to app.jcon and assign a Map of strings.

// config/app.jcon

app {

    // (other fields)

    litemarkCustomTags: {
        tag1: <b>CUSTOM: {1}</b>
        other0: <b>OTHER</b>

See Also