No matching definitions.

tur/markdown/html

stdlib/markdown/html.tur

render a parsed Markdown document as HTML.

The CommonMark spec's HTML, as commonmark.js writes it: the blocks, then each paragraph's, heading's and table cell's inline tree. An image's alt text is its inlines as plain text, escaped. GFM tables and task list items are written as cmark-gfm writes them, and headings get an id when MdHtmlOpts's heading-ids asks for one.

Since: markdown-library-plan M1

defdata

MdRawHtml

(defdata MdRawHtml :copy (MdRawPass) (MdRawTagFilter) (MdRawEscape))

what the renderer does with raw HTML in the document.

MdRawPass writes it through. MdRawTagFilter, the default, is GitHub's behaviour: it writes it through but escapes the < that opens one of nine tags (title, textarea, style, xmp, iframe, noembed, noframes, script, plaintext). MdRawEscape writes all raw HTML as text.

defdata

MdSlugMode

(defdata MdSlugMode :copy (MdNoIds) (MdSlugPython) (MdSlugGitHub))

whether markdown/render-html gives each heading an id, and by which rule.

MdNoIds writes none, as the CommonMark spec and cmark-gfm do. MdSlugPython is python-markdown's toc extension and MdSlugGitHub GitHub's (stdlib/markdown/slug.tur has both rules).

defstruct

MdHtmlOpts

(defstruct MdHtmlOpts :copy [raw-html :MdRawHtml heading-ids :MdSlugMode])

options for markdown/render-html: what to do with raw HTML, and how to give headings ids.

defstruct

MdRen

(defstruct MdRen [nl :bool ids :(Vec String) next :int])

internal: renderer state: whether the output ends with a line feed, the headings' ids, and the next one to write.

defn

md/-out!

(md/-out! [^borrow r :rc<MdRen> b :StringBuilder s :cstr] :void)

internal: append a literal and note whether it ends the line.

defn

md/-cr!

(md/-cr! [^borrow r :rc<MdRen> b :StringBuilder] :void)

internal: start a new line unless the output is at one.

defn

md/-ends-nl?

(md/-ends-nl? [s :String i :int end :int] :bool)

internal: does [i, end) of s end with a line feed?

defn

md/-escape-of

(md/-escape-of [c :int] :cstr)

internal: the entity that stands for byte c in HTML text, or "" when c needs none.

defn

md/-push-escaped!

(md/-push-escaped! [b :StringBuilder s :String i0 :int end :int] :void)

internal: append [i, end) of s with & < > and " escaped.

defn

md/-text!

(md/-text! [^borrow r :rc<MdRen> b :StringBuilder s :String i :int end :int] :void)

internal: append [i, end) of s escaped, tracking the line end.

defn

md/-raw!

(md/-raw! [^borrow r :rc<MdRen> b :StringBuilder s :String i :int end :int] :void)

internal: append [i, end) of s as it is, tracking the line end.

defn

md/-filtered-tag?

(md/-filtered-tag? [s :String i :int end :int] :bool)

internal: does the < at i of s open (or close) one of the nine tags the tag filter escapes?

defn

md/-tag-filtered!

(md/-tag-filtered! [^borrow r :rc<MdRen> b :StringBuilder s :String i0 :int end :int] :void)

internal: append [i, end) of s, escaping the < of a filtered tag.

defn

md/-raw-html!

(md/-raw-html! [^borrow r :rc<MdRen> b :StringBuilder opts :MdHtmlOpts s :String i :int end :int] :void)

internal: append raw HTML [i, end) of s as the options say.

defn

md/-pool

(md/-pool [d :MdDoc i :int] :String)

internal: the document's pool String i (borrowed).

defn

md/-pool-escaped!

(md/-pool-escaped! [d :MdDoc b :StringBuilder v :int] :void)

internal: append pool String v escaped, or nothing when v is -1.

defn

md/-has-pool?

(md/-has-pool? [d :MdDoc v :int] :bool)

internal: is v a pool String that is not empty?

defn

md/-math!

(md/-math! [^borrow r :rc<MdRen> b :StringBuilder alt :bool display :bool s :String i :int end :int] :void)

internal: a formula, [i, end) of s, in a span with its $ or $$ delimiters (display) for KaTeX's auto-render to find; just its text in alt text.

defn

md/-inl-open!

(md/-inl-open! [d :MdDoc ^borrow r :rc<MdRen> b :StringBuilder opts :MdHtmlOpts alt :bool n :MdInl] :void)

internal: what comes before inline n's children; all of a leaf. In alt text (alt) only text is written.

defn

md/-inl-close!

(md/-inl-close! [d :MdDoc ^borrow r :rc<MdRen> b :StringBuilder alt :bool n :MdInl] :void)

internal: what comes after inline n's children.

defn

md/-render-inl!

(md/-render-inl! [d :MdDoc ^borrow r :rc<MdRen> b :StringBuilder opts :MdHtmlOpts alt :bool i :int] :void)

internal: render inline i and everything under it; alt is true inside an image's alt text.

defn

md/-inline!

(md/-inline! [d :MdDoc ^borrow r :rc<MdRen> b :StringBuilder opts :MdHtmlOpts n :MdNode] :void)

internal: a paragraph's or heading's inlines.

defn

md/-block-next

(md/-block-next [d :MdDoc i :int] :int)

internal: the block after block i in document order: its first child, or the next sibling of it or of its nearest ancestor that has one; -1 at the end.

defn

md/-heading-nodes

(md/-heading-nodes [d :MdDoc] :(Vec int))

internal: the heading blocks, in document order.

defn

md/-heading-html

(md/-heading-html [d :MdDoc opts :MdHtmlOpts i :int] :String)

internal: heading block i's inlines as the renderer writes them, with opts.

defn

md/-heading-text-of

(md/-heading-text-of [d :MdDoc opts :MdHtmlOpts i :int collapse :bool] :String)

internal: heading block i as text (md/-heading-plain of its HTML).

defn

md/-heading-ids

(md/-heading-ids [d :MdDoc opts :MdHtmlOpts] :(Vec String))

internal: the id opts gives each heading, in document order; empty under MdNoIds.

defn

md/-tight-para?

(md/-tight-para? [d :MdDoc i :int] :bool)

internal: is node i a paragraph in an item of a tight list (written without <p>)?

defn

md/-text-of

(md/-text-of [d :MdDoc n :MdNode] :String)

internal: node n's pool String (borrowed).

defn

md/-render-code!

(md/-render-code! [d :MdDoc ^borrow r :rc<MdRen> b :StringBuilder n :MdNode] :void)

internal: <pre><code>, with a language class from the info string's first word.

defn

md/-render-math-block!

(md/-render-math-block! [d :MdDoc ^borrow r :rc<MdRen> b :StringBuilder n :MdNode] :void)

internal: a display formula, on its own line; its text's final line feed is left out.

defn

md/-render-heading!

(md/-render-heading! [d :MdDoc ^borrow r :rc<MdRen> b :StringBuilder opts :MdHtmlOpts n :MdNode] :void)

internal: <h1> to <h6>, with the next heading id when there is one and it is not empty.

defn

md/-render-para!

(md/-render-para! [d :MdDoc ^borrow r :rc<MdRen> b :StringBuilder opts :MdHtmlOpts i :int n :MdNode] :void)

internal: <p>, left out in a tight list.

defn

md/-render-html-block!

(md/-render-html-block! [d :MdDoc ^borrow r :rc<MdRen> b :StringBuilder opts :MdHtmlOpts n :MdNode] :void)

internal: an HTML block, as the raw-HTML option says.

defn

md/-open-list!

(md/-open-list! [^borrow r :rc<MdRen> b :StringBuilder l :MdListData] :void)

internal: <ul>, or <ol> with a start attribute unless it starts at 1.

defn

md/-header-row?

(md/-header-row? [d :MdDoc i :int] :bool)

internal: is node i a table's header row?

defn

md/-render-row-open!

(md/-render-row-open! [d :MdDoc ^borrow r :rc<MdRen> b :StringBuilder i :int n :MdNode] :void)

internal: <thead> before the header row, <tbody> before the first other row, then <tr>.

defn

md/-align-attr

(md/-align-attr [a :int] :cstr)

internal: a table cell's align attribute for alignment code a, or "".

defn

md/-render-cell!

(md/-render-cell! [d :MdDoc ^borrow r :rc<MdRen> b :StringBuilder opts :MdHtmlOpts n :MdNode] :void)

internal: a <th> (in the header row) or <td> and its inlines.

defn

md/-render-item-open!

(md/-render-item-open! [^borrow r :rc<MdRen> b :StringBuilder n :MdNode] :void)

internal: <li>, and a disabled checkbox for a task item.

defn

md/-render-open!

(md/-render-open! [d :MdDoc ^borrow r :rc<MdRen> b :StringBuilder opts :MdHtmlOpts i :int] :void)

internal: what comes before node i's children; all of a leaf block.

defn

md/-render-close!

(md/-render-close! [d :MdDoc ^borrow r :rc<MdRen> b :StringBuilder i :int] :void)

internal: what comes after node i's children.

defn

md/-render!

(md/-render! [d :MdDoc ^borrow r :rc<MdRen> b :StringBuilder opts :MdHtmlOpts i :int] :void)

internal: render node i and everything under it.

defn

md/-render-doc

(md/-render-doc [d :MdDoc opts :MdHtmlOpts] :String)

internal: the HTML of document d.

defn

md/-headings-before

(md/-headings-before [d :MdDoc i :int] :int)

internal: how many headings come before block i in document order.

defn

md/-render-block

(md/-render-block [d :MdDoc opts :MdHtmlOpts i :int] :String)

internal: the HTML of block i and everything in it, as the whole document's would have it: its headings keep the ids they get there.