KScript docs
EN

KScript.Markdown

Markdown to HTML, with front matter.

Import it at the top of a script:

<import package="KScript.Markdown" />
import KScript.Markdown

Commands

Commands are called with @, in any expression: @name(arguments).

#@markdown(text, html?: bool) → map

Renders Markdown: $doc.html, $doc.title, $doc.meta (front matter) and $doc.text. Raw HTML in the text is shown as text and javascript: links go nowhere, so a visitor's comment can't add a script; html keeps raw HTML, for text you wrote yourself.
ParameterTakes
text requiredany value
html optionala flag: html or not html

Arguments can be named: @markdown(…, html: …).

Example
<import package="KScript.Markdown" />
<let name="post" value="@markdown('# Hello *world*')" />
<echo>{ $post.title }: { $post.html }</echo>
import KScript.Markdown
$post = @markdown('# Hello *world*')
echo "{ $post.title }: { $post.html }"

#@read_markdown(path) → map

Reads a Markdown file: $doc.html, $doc.title, $doc.meta (front matter) and $doc.text. Relative paths are from the script's folder.
Example
<let name="post" value="@read_markdown('posts/hello.md')" />
$post = @read_markdown('posts/hello.md')

Methods

On string values: ->highlight(), ->markdown_escape()