Module

marksy/html

src/marksy/html.pooka

Dress the syntax tree in HTML without asking it to parse itself again. Raw HTML and links have separate policies: escaping tags alone does not make a javascript link safe. Trusted publishing can preserve raw markup; the default leaves it visible as text.

Pooka
assert html.escape("<owl>") == "&lt;owl&gt;"

API reference

enum

RawHtml

src/marksy/html.pooka:20
enum RawHtml
variant

Escape

src/marksy/html.pooka:21
RawHtml.Escape
variant

Preserve

src/marksy/html.pooka:22
RawHtml.Preserve
variant

Omit

src/marksy/html.pooka:23
RawHtml.Omit
class

Options

src/marksy/html.pooka:26
class Options(raw_html: RawHtml, allow_unsafe_urls: Bool)
field

raw_html

src/marksy/html.pooka:26
raw_html: RawHtml
field

allow_unsafe_urls

src/marksy/html.pooka:26
allow_unsafe_urls: Bool
INFERREDBool
constructor

new

src/marksy/html.pooka:26
function

defaults

src/marksy/html.pooka:30
defaults() -> Options
INFERREDfn() -> marksy/html.Options

Safe defaults for application rendering. CommonMark conformance uses an explicit Preserve policy because the specification includes raw HTML.

function

escape

src/marksy/html.pooka:34
escape(source: String) -> String
INFERREDfn(String) -> String
function

render

src/marksy/html.pooka:43
render(document: ast.Document) -> String
INFERREDfn(marksy/ast.Document) -> String

Render with escaped raw HTML and restricted URL destinations.

Pooka
assert html.render(marksy.parse("# Owl")) == "<h1>Owl</h1>\n"
function

render_with

src/marksy/html.pooka:54
render_with(document: ast.Document, options: Options) -> String

Select HTML policy independently from the Markdown extensions.

Pooka
let policy = html.Options(html.RawHtml.Preserve, False)
let page = marksy.parse("a <b>small</b> owl")
assert html.render_with(page, policy) == "<p>a <b>small</b> owl</p>\n"
function

inlines

src/marksy/html.pooka:112
inlines(content: List(ast.Inline), options: Options) -> String
INFERREDfn(List(marksy/ast.Inline), marksy/html.Options) -> String