~/bend-docscommunity

markdown.bend checks

raw source on the hub · import bend-kit-markdown@0.2.0.0/markdown.bend as Markdown

CommonMark 0.31.2: Markdown to HTML.

3 imports
import Base
import bend-kit-unicode@0.1.0.0/unicode.bend as U
import ./entities.bend as E

Types

type Got source · line 78 · raw

Data

A parsed value and the text after it.

type Ch source · line 298 · raw

Data

A scanner's view of the next code point.

type Dk source · line 362 · raw

Data

type Ref source · line 451 · raw

Data

type RefGot source · line 455 · raw

Data

A parsed definition and the text after it.

type Mark source · line 633 · raw

Data

type Kid source · line 638 · raw

Data

A block and whether the last line it took was blank, for tight and loose lists.

type Block source · line 641 · raw

Data

type Frame source · line 652 · raw

Data

An open container. kids are newest first.

type Leaf source · line 658 · raw

Data

The open leaf of the innermost container. lines are newest first.

type St source · line 666 · raw

Data

The parser between lines. stack is innermost first and ends with FDoc.

type Ln source · line 670 · raw

Data

The rest of a line and the column it starts at.

type G source · line 720 · raw

Data

type Cx source · line 913 · raw

Data

A line at the current container: the line, the line at its first non-space, the indent in columns, and blankness.

type Hd source · line 942 · raw

Data

type Fg source · line 957 · raw

Data

type Im source · line 988 · raw

Data

A list marker: its kind, start number, and width in characters.

type W source · line 1091 · raw

Data

type Lm source · line 1113 · raw

Data

type Lk source · line 1140 · raw

Data

type P source · line 1147 · raw

Data

A line in progress. pops counts the containers it did not continue. tipp: the leaf was a paragraph when the line began.

type Sr source · line 1150 · raw

Data

type Inl source · line 1524 · raw

Data

An inline in progress. IHtml is finished output and its plain text, for image alt text.

type Fd source · line 1562 · raw

Data

A matching opener: the inlines after it (oldest first), the opener, and the stack below it.

type Rs source · line 1565 · raw

Data

type Is source · line 1644 · raw

Data

type Bk source · line 1812 · raw

Data

Splits the output at its newest bracket: the inlines after it (oldest first), the bracket, and the rest.

type Lt source · line 1833 · raw

Data

type Ic source · line 1947 · raw

Data

Definitions

def hd source · line 9 · raw

@s:String -> U32

The first code point of s; 0 when s is empty.

def eq source · line 16 · raw

@+a:U32 -> @+b:U32 -> Bool

def within source · line 19 · raw

@+c:U32 -> @+lo:U32 -> @+hi:U32 -> Bool

def one source · line 22 · raw

@+c:U32 -> String

def is_sp source · line 25 · raw

@+c:U32 -> Bool

def is_nl source · line 28 · raw

@+c:U32 -> Bool

def is_digit source · line 31 · raw

@+c:U32 -> Bool

def is_hex source · line 34 · raw

@+c:U32 -> Bool

def is_alpha source · line 37 · raw

@+c:U32 -> Bool

def is_alnum source · line 40 · raw

@+c:U32 -> Bool

def is_apunct source · line 43 · raw

@+c:U32 -> Bool

def cat_ps source · line 46 · raw

@s:String -> Bool

def is_punct.go source · line 50 · raw

@big:Bool -> @+c:U32 -> Bool

def is_punct source · line 58 · raw

@+c:U32 -> Bool

Unicode punctuation: general category P or S.

def is_uws.go source · line 61 · raw

@big:Bool -> @+c:U32 -> Bool

def is_uws source · line 69 · raw

@+c:U32 -> Bool

Unicode whitespace: general category Zs, tab, LF, FF, or CR. 0 stands for the edge of the text.

def lower source · line 72 · raw

@+c:U32 -> U32

def fst source · line 81 · raw

@r:Pair(String, String) -> String

def snd source · line 85 · raw

@r:Pair(String, String) -> String

def span.cons source · line 89 · raw

@+y:U32 -> @r:Pair(String, String) -> Pair(String, String)

def count.go source · line 111 · raw

@+k:U32 -> @s:String -> @ok:Bool -> Nat

def count source · line 123 · raw

@+k:U32 -> @+s:String -> Nat

How many times k repeats at the start of s.

def lit source · line 126 · raw

@+p:String -> @+s:String -> Maybe<&2, String>

def lower_s source · line 129 · raw

@s:String -> String

def lit_ci source · line 137 · raw

@+p:String -> @+s:String -> Maybe<&2, String>

p must be lower case; s matches it in any ASCII case.

def is_blank source · line 141 · raw

@s:String -> Bool

def trim_sp source · line 144 · raw

@s:String -> String

def has_ci source · line 148 · raw

@s:String -> @+p:String -> Bool

s holds p somewhere, ASCII case aside; p is lower case.

def esc source · line 153 · raw

@s:String -> String

def hexd source · line 165 · raw

@+n:U32 -> U32

def pct source · line 168 · raw

@+b:U32 -> String

def pct_utf8 source · line 172 · raw

@+c:U32 -> String

Each UTF-8 octet of c as %XX.

def href_safe source · line 178 · raw

@+c:U32 -> Bool

def href source · line 182 · raw

@s:String -> String

A URL for an href or src attribute: unsafe octets percent-encoded, & and ' as references.

def num.dec source · line 195 · raw

@s:String -> @acc:U32 -> U32

def hexv source · line 202 · raw

@+c:U32 -> U32

def num.hex source · line 205 · raw

@s:String -> @acc:U32 -> U32

def cp_ok source · line 212 · raw

@+n:U32 -> U32

def ent.num source · line 215 · raw

@+d:String -> @+rest:String -> @+lo:Nat -> @+hi:Nat -> @v:U32 -> Maybe<&2, Got>

def ent.named.go source · line 219 · raw

@m:Maybe<&2, String> -> @+rest:String -> Maybe<&2, Got>

def ent.named source · line 226 · raw

@r:Pair(String, String) -> Maybe<&2, Got>

def ent.hash source · line 230 · raw

@r:Pair(String, String) -> Maybe<&2, Got>

def ent.hex source · line 234 · raw

@r:Pair(String, String) -> Maybe<&2, Got>

def ent.sharp source · line 238 · raw

@+s:String -> Maybe<&2, Got>

def ent.pick source · line 242 · raw

@sharp:Bool -> @+s:String -> Maybe<&2, Got>

def ent source · line 250 · raw

@+s:String -> Maybe<&2, Got>

s follows an &: the decoded reference and the text after its ;.

def unesc.ent source · line 255 · raw

@m:Maybe<&2, Got> -> @+y:U32 -> @+t:String -> Got

def unesc.amp source · line 262 · raw

@amp:Bool -> @+y:U32 -> @+t:String -> Got

def unesc.step source · line 270 · raw

@+y:U32 -> @+t:String -> Got

One step: the text the code point y (with t after it) stands for, and the rest.

def revapp source · line 273 · raw

@a:String -> @b:String -> String

def unesc.go source · line 280 · raw

@f:Nat -> @g:Got -> @acc:String -> String

def unesc source · line 294 · raw

@+s:String -> String

Backslash escapes and character references resolved.

def ch source · line 306 · raw

@+c:U32 -> @+open:U32 -> @+close:U32 -> Ch

def esc_ch source · line 314 · raw

@+c:U32 -> Ch

The class of a code point after a backslash: never a delimiter.

def label.go source · line 317 · raw

@s:String -> @k:Ch -> @acc:String -> Maybe<&2, Got>

def label.ok source · line 332 · raw

@m:Maybe<&2, Got> -> Maybe<&2, Got>

def label source · line 340 · raw

@+s:String -> Maybe<&2, Got>

s follows a [: the raw label up to the matching ], and the text after the ].

def dest.lt.go source · line 343 · raw

@s:String -> @k:Ch -> @acc:String -> Maybe<&2, Got>

def dk source · line 369 · raw

@+c:U32 -> @+depth:U32 -> Dk

def dest.go source · line 375 · raw

@s:String -> @k:Dk -> @+depth:U32 -> @acc:String -> Pair(Got, U32)

def dest.plain source · line 392 · raw

@r:Pair(Got, U32) -> Maybe<&2, Got>

def dest.pick source · line 398 · raw

@lt:Bool -> @+s:String -> Maybe<&2, Got>

def dest source · line 407 · raw

@+s:String -> Maybe<&2, Got>

A link destination, raw: <...> or a run with balanced parentheses.

def title.go source · line 410 · raw

@s:String -> @k:Ch -> @+open:U32 -> @+close:U32 -> @acc:String -> Maybe<&2, Got>

def title.of source · line 429 · raw

@+q:U32 -> @+s:String -> Maybe<&2, Got>

def title source · line 436 · raw

@+s:String -> Maybe<&2, Got>

A link title, raw: "...", '...', or (...).

def ws1 source · line 441 · raw

@+s:String -> String

Spaces and tabs, with at most one line ending among them.

def eol source · line 446 · raw

@+s:String -> Maybe<&2, String>

The end of a line: spaces and tabs, then a line ending or the end of s.

def norm.go source · line 458 · raw

@s:String -> @+ws:Bool -> @+acc:String -> String

def norm source · line 467 · raw

@s:String -> String

A label for matching: case-folded, inner whitespace runs as one space, trimmed.

def alt source · line 470 · raw

@a:Maybe<&2, RefGot> -> @b:Maybe<&2, RefGot> -> Maybe<&2, RefGot>

def refdef.title source · line 477 · raw

@+lab:String -> @+d:String -> @tg:Got -> Maybe<&2, RefGot>

def refdef.titled source · line 484 · raw

@+lab:String -> @+d:String -> @+rest:String -> Maybe<&2, RefGot>

def refdef.bare source · line 491 · raw

@+lab:String -> @+d:String -> @+rest:String -> Maybe<&2, RefGot>

def refdef.dest source · line 496 · raw

@+lab:String -> @dg:Got -> Maybe<&2, RefGot>

def refdef.label source · line 501 · raw

@lg:Got -> Maybe<&2, RefGot>

def refdef source · line 511 · raw

@+s:String -> Maybe<&2, RefGot>

A link reference definition at the start of s.

def cut.go source · line 520 · raw

@+s:String -> @hit:Bool -> @+pat:String -> Maybe<&2, String>

def cut source · line 532 · raw

@+s:String -> @+pat:String -> Maybe<&2, String>

The text after the first pat in s.

def is_wsn source · line 535 · raw

@+c:U32 -> Bool

def wsp source · line 538 · raw

@+s:String -> String

def need source · line 541 · raw

@ok:Bool -> @+s:String -> Maybe<&2, String>

def tagname source · line 544 · raw

@+s:String -> Maybe<&2, String>

def attrname source · line 547 · raw

@+s:String -> Maybe<&2, String>

def unquoted source · line 551 · raw

@+c:U32 -> Bool

def attrval source · line 554 · raw

@+s:String -> Maybe<&2, String>

def or source · line 559 · raw

@a:Maybe<&2, String> -> @b:Maybe<&2, String> -> Maybe<&2, String>

def attr.value source · line 566 · raw

@+s:String -> Maybe<&2, String>

def attr source · line 572 · raw

@+s:String -> Maybe<&2, String>

def attrs.go source · line 578 · raw

@f:Nat -> @m:Maybe<&2, String> -> @+s:String -> String

def attrs source · line 589 · raw

@+s:String -> String

def open_tag source · line 592 · raw

@+s:String -> Maybe<&2, String>

def close_tag source · line 600 · raw

@+s:String -> Maybe<&2, String>

def comment source · line 607 · raw

@+s:String -> Maybe<&2, String>

def decl source · line 613 · raw

@+s:String -> Maybe<&2, String>

def cut.after source · line 620 · raw

@m:Maybe<&2, String> -> @+pat:String -> Maybe<&2, String>

def raw_html source · line 628 · raw

@+s:String -> Maybe<&2, String>

Raw inline HTML at the start of s: the text after it.

def same_kind source · line 673 · raw

@a:Mark -> @b:Mark -> Bool

def is_ord source · line 682 · raw

@k:Mark -> Bool

def ends source · line 690 · raw

@ks:List<&2, Kid> -> Bool

Does the last of ks end with a blank line, looking into lists and items?

def loose.sub source · line 703 · raw

@ks:List<&2, Kid> -> @+next:Bool -> Bool

def loose source · line 710 · raw

@items:List<&2, Kid> -> Bool

def g_flush source · line 723 · raw

@g:G -> List<&2, Kid>

def g_same source · line 733 · raw

@g:G -> @k:Mark -> Bool

def group.item source · line 738 · raw

@same:Bool -> @g:G -> @+k:Kid -> @+kind:Mark -> @+start:U32 -> G

def group.step source · line 747 · raw

@+g:G -> @k:Kid -> G

def group.go source · line 754 · raw

@ks:List<&2, Kid> -> @+g:G -> List<&2, Kid>

def group source · line 762 · raw

@ks:List<&2, Kid> -> List<&2, Kid>

Runs of items of one kind become lists.

def push_kid source · line 765 · raw

@f:Frame -> @k:Kid -> Frame

def add_kid source · line 774 · raw

@stack:List<&2, Frame> -> @k:Kid -> List<&2, Frame>

def join_rev source · line 781 · raw

@lines:List<&2, String> -> String

def drop_blank_lines source · line 784 · raw

@lines:List<&2, String> -> List<&2, String>

def has_ref source · line 791 · raw

@refs:List<&2, Ref> -> @+label:String -> Bool

def add_ref source · line 799 · raw

@+refs:List<&2, Ref> -> @r:Ref -> List<&2, Ref>

The first definition of a label wins.

def defs.go source · line 804 · raw

@f:Nat -> @m:Maybe<&2, RefGot> -> @+s:String -> @+refs:List<&2, Ref> -> Pair(String, List<&2, Ref>)

def defs source · line 816 · raw

@+s:String -> @refs:List<&2, Ref> -> Pair(String, List<&2, Ref>)

The link reference definitions at the start of a paragraph, and the text after them.

def para.close source · line 819 · raw

@+llb:Bool -> @r:Pair(String, List<&2, Ref>) -> @+stack:List<&2, Frame> -> @+line:U32 -> St

def fence.body source · line 823 · raw

@+lines:List<&2, String> -> String

def close_leaf source · line 826 · raw

@st:St -> St

def frame_kid source · line 841 · raw

@f:Frame -> Kid

def close_frame source · line 851 · raw

@st:St -> St

Closes the innermost container; its leaf must be closed.

def pop source · line 860 · raw

@n:Nat -> @st:St -> St

def ln_s source · line 869 · raw

@ln:Ln -> String

def ln_col source · line 874 · raw

@ln:Ln -> U32

def tabw source · line 879 · raw

@+col:U32 -> U32

def adv.w source · line 882 · raw

@+c:U32 -> @+col:U32 -> U32

def adv.go source · line 886 · raw

@+s:String -> @go:Bool -> @full:Bool -> @+n:U32 -> @+col:U32 -> Ln

go: s starts with a space or tab and n > 0. full: that character fits in n columns.

def adv source · line 904 · raw

@ln:Ln -> @+n:U32 -> Ln

Consumes up to n columns of leading spaces and tabs. A tab it cuts leaves its other columns as spaces.

def ns source · line 909 · raw

@ln:Ln -> Ln

def cx source · line 916 · raw

@+ln:Ln -> Cx

def cx_ln source · line 920 · raw

@c:Cx -> Ln

def cx_at source · line 925 · raw

@c:Cx -> Ln

def cx_ind source · line 930 · raw

@c:Cx -> U32

def cx_blank source · line 935 · raw

@c:Cx -> Bool

def atx.text source · line 945 · raw

@+t:String -> String

def atx.of source · line 950 · raw

@+n:Nat -> @+r:String -> Maybe<&2, Hd>

def atx source · line 953 · raw

@+s:String -> Maybe<&2, Hd>

def fence source · line 960 · raw

@+s:String -> Maybe<&2, Fg>

def close_fence source · line 966 · raw

@+s:String -> @+c:U32 -> @+n:U32 -> Bool

def hr.go source · line 970 · raw

@s:String -> @+c:U32 -> @+n:Nat -> Bool

def hr source · line 977 · raw

@+s:String -> Bool

def setext source · line 982 · raw

@+s:String -> U32

1 for a = underline, 2 for -, 0 for neither.

def item.ord source · line 991 · raw

@+d:String -> @+r:String -> Maybe<&2, Im>

def item.of source · line 997 · raw

@r:Pair(String, String) -> Maybe<&2, Im>

def item.scan source · line 1001 · raw

@+s:String -> Maybe<&2, Im>

def blocknames source · line 1006 · raw

List<&2, String>

def member source · line 1009 · raw

@xs:List<&2, String> -> @+n:String -> Bool

def html6 source · line 1016 · raw

@+s:String -> Bool

def html1.one source · line 1022 · raw

@m:Maybe<&2, String> -> Bool

def html1 source · line 1030 · raw

@+s:String -> Bool

def html7.ok source · line 1033 · raw

@m:Maybe<&2, String> -> Bool

def html_start.lt source · line 1040 · raw

@lt:Bool -> @+s:String -> @+cpara:Bool -> U32

def html_start source · line 1054 · raw

@+s:String -> @+cpara:Bool -> U32

The HTML block kind (1 to 7) that a line at s starts, or 0.

def html_end source · line 1057 · raw

@+k:U32 -> @+s:String -> Bool

def after_gt source · line 1066 · raw

@at:Ln -> Ln

def quote_cont source · line 1071 · raw

@c:Cx -> Maybe<&2, Ln>

def item_cont source · line 1076 · raw

@+hc:Bool -> @+pad:U32 -> @c:Cx -> Maybe<&2, Ln>

def cont source · line 1082 · raw

@f:Frame -> @c:Cx -> @+hc:Bool -> Maybe<&2, Ln>

The line after f's own prefix, or None when f does not continue. hc: f has a child besides its kids.

def walk.head source · line 1094 · raw

@frames:List<&2, Frame> -> @+ln:Ln -> @+leafnone:Bool -> Maybe<&2, Ln>

def walk source · line 1102 · raw

@frames:List<&2, Frame> -> @m:Maybe<&2, Ln> -> @+ln:Ln -> @+k:Nat -> @+leafnone:Bool -> W

m is the head frame's continuation. k counts the frames that continued.

def leaf_cont source · line 1119 · raw

@leaf:Leaf -> @c:Cx -> Lm

def p_ln source · line 1155 · raw

@p:P -> Ln

def p_tipp source · line 1160 · raw

@p:P -> Bool

def p_cpara source · line 1165 · raw

@p:P -> Bool

def p_line source · line 1174 · raw

@p:P -> U32

def push_frame source · line 1179 · raw

@st:St -> @f:Frame -> St

def set_leaf source · line 1184 · raw

@st:St -> @leaf:Leaf -> St

def add_kid_st source · line 1189 · raw

@st:St -> @k:Kid -> St

def unmatched source · line 1195 · raw

@p:P -> P

Closes the containers, and the leaf, that the line did not continue.

def prep.go source · line 1204 · raw

@p:P -> St

def prep source · line 1210 · raw

@p:P -> St

Ready for a new block: unmatched blocks closed, and the leaf closed.

def try.code source · line 1213 · raw

@+p:P -> @c:Cx -> Sr

def item.open source · line 1218 · raw

@im:Im -> @+p:P -> @+c:Cx -> Sr

def try.item source · line 1230 · raw

@m:Maybe<&2, Im> -> @+p:P -> @+c:Cx -> Sr

def try.hr source · line 1237 · raw

@ok:Bool -> @+p:P -> @+c:Cx -> Sr

def setext.close source · line 1244 · raw

@+lv:U32 -> @r:Pair(String, List<&2, Ref>) -> @+stack:List<&2, Frame> -> @+line:U32 -> @+p:P -> Sr

def setext.apply source · line 1248 · raw

@+lv:U32 -> @+p:P -> Sr

def try.setext source · line 1257 · raw

@ok:Bool -> @+lv:U32 -> @+p:P -> @+c:Cx -> Sr

def html.open source · line 1264 · raw

@+k:U32 -> @+p:P -> @+c:Cx -> Sr

def try.html source · line 1269 · raw

@+k:U32 -> @+p:P -> @+c:Cx -> Sr

def try.fence source · line 1273 · raw

@m:Maybe<&2, Fg> -> @+p:P -> @+c:Cx -> Sr

def try.atx source · line 1280 · raw

@m:Maybe<&2, Hd> -> @+p:P -> @+c:Cx -> Sr

def try.quote source · line 1287 · raw

@ok:Bool -> @+p:P -> @+c:Cx -> Sr

def starts.try source · line 1294 · raw

@+p:P -> Sr

def starts.go source · line 1298 · raw

@f:Nat -> @r:Sr -> Sr

def f_reset source · line 1311 · raw

@f:Frame -> Frame

def reset_all source · line 1320 · raw

@stack:List<&2, Frame> -> List<&2, Frame>

def kid_blank source · line 1327 · raw

@ks:List<&2, Kid> -> List<&2, Kid>

def f_blank source · line 1335 · raw

@f:Frame -> @+line:U32 -> Frame

A blank line went to f: its last child ends blank, and so does f unless it is a quote or an item that began on this line with no child.

def reset_llb source · line 1344 · raw

@st:St -> St

def head_blank source · line 1349 · raw

@st:St -> St

def leaf_llb source · line 1358 · raw

@st:St -> @+blank:Bool -> St

def st_leaf source · line 1369 · raw

@st:St -> Leaf

def leaf_none source · line 1374 · raw

@leaf:Leaf -> Bool

def leaf_para source · line 1381 · raw

@leaf:Leaf -> Bool

def leaf_add source · line 1388 · raw

@st:St -> @+s:String -> St

def text.put source · line 1404 · raw

@p:P -> @+c:Cx -> St

def text.lazy source · line 1415 · raw

@lazy:Bool -> @+p:P -> @+c:Cx -> St

def text.add source · line 1425 · raw

@+p:P -> St

The rest of a line after block starts: a lazy paragraph line, a leaf's line, a new paragraph, or a blank.

def line.fin source · line 1433 · raw

@r:Sr -> St

def line.run source · line 1442 · raw

@p:P -> @+ln:Ln -> St

def line.lm source · line 1445 · raw

@m:Lm -> @+st:St -> @+ln:Ln -> @+tipp:Bool -> St

def line.pops source · line 1456 · raw

@un:Bool -> @+pops:Nat -> @+st:St -> @+ln:Ln -> @+tipp:Bool -> St

def line.walked source · line 1463 · raw

@w:W -> @+st:St -> @+depth:Nat -> @+tipp:Bool -> St

def line source · line 1469 · raw

@st:St -> @raw:String -> St

def doc.go source · line 1477 · raw

@lines:List<&2, String> -> @st:St -> St

def finish.doc source · line 1484 · raw

@st:St -> Pair(List<&2, Kid>, List<&2, Ref>)

def finish source · line 1493 · raw

@st:St -> Pair(List<&2, Kid>, List<&2, Ref>)

def clean source · line 1498 · raw

@s:String -> String

def drop_cr source · line 1505 · raw

@+l:String -> String

def lines.go source · line 1508 · raw

@xs:List<&2, String> -> List<&2, String>

def blocks source · line 1518 · raw

@s:String -> Pair(List<&2, Kid>, List<&2, Ref>)

The block tree and the link reference definitions of a document.

def rep source · line 1530 · raw

@+c:U32 -> @n:U32 -> String

def r.inl source · line 1533 · raw

@xs:List<&2, Inl> -> String

def p.inl source · line 1546 · raw

@xs:List<&2, Inl> -> String

def odd_fail source · line 1571 · raw

@+ocl:Bool -> @+o:U32 -> @+copen:Bool -> @+orig:U32 -> Bool

Rule of three: a run that can both open and close matches only if the lengths do not sum to a multiple of 3, unless both are.

def find source · line 1574 · raw

@stack:List<&2, Inl> -> @+c:U32 -> @+orig:U32 -> @+copen:Bool -> @+acc:List<&2, Inl> -> Maybe<&2, Fd>

def rs.of source · line 1583 · raw

@m:Maybe<&2, Fd> -> Rs

def seek source · line 1590 · raw

@more:Bool -> @stack:List<&2, Inl> -> @+c:U32 -> @+orig:U32 -> @+copen:Bool -> Rs

def wrap source · line 1597 · raw

@+use:U32 -> @+xs:List<&2, Inl> -> Inl

def keep source · line 1602 · raw

@+n:U32 -> @+c:U32 -> @+o:U32 -> @+op:Bool -> @+cl:Bool -> @+below:List<&2, Inl> -> List<&2, Inl>

def resolve source · line 1606 · raw

@f:Nat -> @r:Rs -> @+stack:List<&2, Inl> -> @+c:U32 -> @+n:U32 -> @+orig:U32 -> @+copen:Bool -> List<&2, Inl>

Matches the closer, n long, against openers until it runs out or none is left.

def emph.delim source · line 1622 · raw

@cl:Bool -> @+stack:List<&2, Inl> -> @+c:U32 -> @+n:U32 -> @+o:U32 -> @+op:Bool -> List<&2, Inl>

def emph.go source · line 1629 · raw

@xs:List<&2, Inl> -> @+stack:List<&2, Inl> -> List<&2, Inl>

def emph source · line 1639 · raw

@xs:List<&2, Inl> -> List<&2, Inl>

Emphasis and strong emphasis, by the delimiter run rules.

def flush source · line 1647 · raw

@+buf:String -> @+out:List<&2, Inl> -> List<&2, Inl>

def tick.go source · line 1650 · raw

@s:String -> @hit:Bool -> @+run:Nat -> @+n:Nat -> @acc:String -> Maybe<&2, Got>

def cnl source · line 1666 · raw

@s:String -> String

def cnorm source · line 1674 · raw

@+s:String -> String

Code span text: line endings as spaces, and one space stripped from each end when both ends have one.

def code.got source · line 1678 · raw

@m:Maybe<&2, Got> -> @+ticks:Nat -> @+after:String -> @+buf:String -> @out:List<&2, Inl> -> Is

def code source · line 1686 · raw

@+s:String -> @+buf:String -> @out:List<&2, Inl> -> Is

def scheme_ch source · line 1691 · raw

@+c:U32 -> Bool

def uri_ch source · line 1694 · raw

@+c:U32 -> Bool

def auto.uri source · line 1697 · raw

@+t:String -> Maybe<&2, Got>

def email_ch source · line 1705 · raw

@+c:U32 -> Bool

def dom_ch source · line 1708 · raw

@+c:U32 -> Bool

def dom.parts source · line 1711 · raw

@xs:List<&2, String> -> Bool

def dom_ok source · line 1719 · raw

@+d:String -> Bool

def auto.email source · line 1723 · raw

@+t:String -> Maybe<&2, Got>

def url.has.of source · line 1730 · raw

@m:Maybe<&2, String> -> Bool

def url.has source · line 1737 · raw

@+p:String -> @+s:String -> Bool

def url.bad source · line 1741 · raw

@+s:String -> Bool

cmark's unsafe schemes. A data: image in PNG, GIF, JPEG, or WebP is safe.

def url source · line 1746 · raw

@safe:Bool -> @+s:String -> String

An href or src value. In safe mode an unsafe URL becomes empty.

def raw_or_omit source · line 1753 · raw

@safe:Bool -> @+raw:String -> String

def lt.html source · line 1756 · raw

@m:Maybe<&2, String> -> @+s:String -> @+buf:String -> @out:List<&2, Inl> -> @+safe:Bool -> Is

def lt.email source · line 1764 · raw

@m:Maybe<&2, Got> -> @+s:String -> @+buf:String -> @out:List<&2, Inl> -> @+safe:Bool -> Is

def lt.uri source · line 1771 · raw

@m:Maybe<&2, Got> -> @+s:String -> @+buf:String -> @out:List<&2, Inl> -> @+safe:Bool -> Is

def amp.got source · line 1778 · raw

@m:Maybe<&2, Got> -> @+t:String -> @buf:String -> @out:List<&2, Inl> -> Is

def nl source · line 1786 · raw

@+t:String -> @+buf:String -> @out:List<&2, Inl> -> Is

Trailing spaces before a line ending: two or more make a hard break.

def bs source · line 1791 · raw

@+t:String -> @+buf:String -> @+out:List<&2, Inl> -> Is

def delim source · line 1797 · raw

@+c:U32 -> @+s:String -> @+prev:U32 -> @+buf:String -> @out:List<&2, Inl> -> Is

def brk source · line 1815 · raw

@out:List<&2, Inl> -> @acc:List<&2, Inl> -> Maybe<&2, Bk>

def deact source · line 1824 · raw

@xs:List<&2, Inl> -> List<&2, Inl>

def find_ref source · line 1836 · raw

@refs:List<&2, Ref> -> @+label:String -> Maybe<&2, Ref>

def lookup.got source · line 1843 · raw

@m:Maybe<&2, Ref> -> @+rest:String -> Maybe<&2, Lt>

def lookup source · line 1850 · raw

@+refs:List<&2, Ref> -> @+raw:String -> @+rest:String -> Maybe<&2, Lt>

def ref.full source · line 1853 · raw

@m:Maybe<&2, Got> -> @+t:String -> @+raw:String -> @+refs:List<&2, Ref> -> Maybe<&2, Lt>

def ref.tail source · line 1860 · raw

@+t:String -> @+raw:String -> @+refs:List<&2, Ref> -> Maybe<&2, Lt>

def inl.close.of source · line 1863 · raw

@+d:String -> @v:String -> @m:Maybe<&2, String> -> Maybe<&2, Lt>

def inl.close source · line 1870 · raw

@+d:String -> @tg:Got -> Maybe<&2, Lt>

def inl.title source · line 1875 · raw

@+d:String -> @+c:String -> Maybe<&2, Lt>

def inl.dest source · line 1881 · raw

@+d:String -> @+r:String -> Maybe<&2, Lt>

def inl.got source · line 1885 · raw

@m:Maybe<&2, Got> -> Maybe<&2, Lt>

def inl.open source · line 1892 · raw

@+b:String -> Maybe<&2, Lt>

def inl.tail source · line 1896 · raw

@+t:String -> Maybe<&2, Lt>

An inline link's (destination "title").

def lt_or source · line 1899 · raw

@a:Maybe<&2, Lt> -> @b:Maybe<&2, Lt> -> Maybe<&2, Lt>

def title_attr source · line 1906 · raw

@m:Maybe<&2, String> -> String

def link.make source · line 1913 · raw

@lt:Lt -> @xs:List<&2, Inl> -> @+img:Bool -> @+below:List<&2, Inl> -> @+safe:Bool -> Is

def link.fail source · line 1923 · raw

@above:List<&2, Inl> -> @+img:Bool -> @below:List<&2, Inl> -> @+t:String -> Is

def link.try source · line 1926 · raw

@m:Maybe<&2, Lt> -> @above:List<&2, Inl> -> @+img:Bool -> @below:List<&2, Inl> -> @+t:String -> @+safe:Bool -> Is

def close.br source · line 1933 · raw

@m:Maybe<&2, Bk> -> @+t:String -> @+out:List<&2, Inl> -> @+refs:List<&2, Ref> -> @+safe:Bool -> Is

def ic source · line 1959 · raw

@+c:U32 -> @+nx:U32 -> Ic

def istep source · line 1970 · raw

@k:Ic -> @+y:U32 -> @+t:String -> @+prev:U32 -> @+buf:String -> @+out:List<&2, Inl> -> @+refs:List<&2, Ref> -> @+safe:Bool -> Is

def inl.go source · line 1993 · raw

@f:Nat -> @st:Is -> @+refs:List<&2, Ref> -> @+safe:Bool -> List<&2, Inl>

def inline source · line 2007 · raw

@+s:String -> @+refs:List<&2, Ref> -> @+safe:Bool -> String

A paragraph or heading's text as HTML.

def cr source · line 2012 · raw

@+out:String -> String

def put source · line 2015 · raw

@s:String -> @out:String -> String

def code_open source · line 2018 · raw

@+info:String -> String

def list_open source · line 2022 · raw

@+ord:Bool -> @+start:U32 -> String

def r.go source · line 2026 · raw

@ks:List<&2, Kid> -> @+tight:Bool -> @+refs:List<&2, Ref> -> @+safe:Bool -> @+out:String -> String

out is reversed. tight: these kids are the children of an item in a tight list.

def render source · line 2048 · raw

@+safe:Bool -> @r:Pair(List<&2, Kid>, List<&2, Ref>) -> String

def to_html source · line 2053 · raw

@s:String -> String

CommonMark to HTML. Raw HTML and every URL pass through, as the spec requires.

def to_html_safe source · line 2057 · raw

@s:String -> String

CommonMark to HTML for untrusted input, as cmark renders without --unsafe: raw HTML becomes a comment, and a javascript:, vbscript:, file:, or data: URL becomes empty.

Templates

template span.go source · line 93 · raw

@-p:(@_:U32 -> Bool) -> @s:String -> @ok:Bool -> Pair(String, String)

template span source · line 105 · raw

@-p:(@_:U32 -> Bool) -> @+s:String -> Pair(String, String)

The longest prefix of s whose code points satisfy p, and the rest.

template skip source · line 108 · raw

@-p:(@_:U32 -> Bool) -> @+s:String -> String