~/bend-docscommunity

markdown.bend checks

raw source on the hub · import bend-kit-markdown@0.3.1.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 86 · raw

Data

A parsed value and the text after it.

type Ch source · line 334 · raw

Data

A scanner's view of the next code point.

type Dk source · line 398 · raw

Data

type Ref source · line 487 · raw

Data

type RefGot source · line 491 · raw

Data

A parsed definition and the text after it.

type Mark source · line 669 · raw

Data

type Kid source · line 674 · raw

Data

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

type Block source · line 677 · raw

Data

type Frame source · line 688 · raw

Data

An open container. kids are newest first.

type Leaf source · line 694 · raw

Data

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

type St source · line 702 · raw

Data

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

type Ln source · line 706 · raw

Data

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

type G source · line 756 · raw

Data

type Cx source · line 949 · 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 978 · raw

Data

type Fg source · line 993 · raw

Data

type Im source · line 1024 · raw

Data

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

type W source · line 1127 · raw

Data

type Lm source · line 1149 · raw

Data

type Lk source · line 1176 · raw

Data

type P source · line 1183 · 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 1186 · raw

Data

type Inl source · line 1560 · raw

Data

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

type Fd source · line 1598 · raw

Data

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

type Rs source · line 1601 · raw

Data

type Is source · line 1681 · raw

Data

type Opts source · line 1791 · raw

Data

Render options. safe renders as cmark without --unsafe. gfm turns on the GitHub extensions.

type Ak source · line 1943 · raw

Data

type Al source · line 1982 · raw

Data

type Bk source · line 2064 · raw

Data

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

type Lt source · line 2085 · raw

Data

type Ic source · line 2199 · raw

Data

type Tb source · line 2330 · raw

Data

A table in a paragraph: the lines before its header row, the header cells, the alignments, and the body rows.

Definitions

def when source · line 7 · raw

@-A:Type -> @c:Bool -> @t:(@_:Unit -> A) -> @e:(@_:Unit -> A) -> A

Bool.pick evaluates both branches; when evaluates only the chosen one.

def hd source · line 17 · raw

@s:String -> U32

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

def eq source · line 24 · raw

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

def within source · line 27 · raw

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

def one source · line 30 · raw

@+c:U32 -> String

def is_sp source · line 33 · raw

@+c:U32 -> Bool

def is_nl source · line 36 · raw

@+c:U32 -> Bool

def is_digit source · line 39 · raw

@+c:U32 -> Bool

def is_hex source · line 42 · raw

@+c:U32 -> Bool

def is_alpha source · line 45 · raw

@+c:U32 -> Bool

def is_alnum source · line 48 · raw

@+c:U32 -> Bool

def is_apunct source · line 51 · raw

@+c:U32 -> Bool

def cat_ps source · line 54 · raw

@s:String -> Bool

def is_punct.go source · line 58 · raw

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

def is_punct source · line 66 · raw

@+c:U32 -> Bool

Unicode punctuation: general category P or S.

def is_uws.go source · line 69 · raw

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

def is_uws source · line 77 · 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 80 · raw

@+c:U32 -> U32

def fst source · line 89 · raw

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

def snd source · line 93 · raw

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

def span.cons source · line 97 · raw

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

def count.go source · line 119 · raw

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

def count source · line 131 · raw

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

How many times k repeats at the start of s.

def lit source · line 134 · raw

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

def lower_s source · line 137 · raw

@s:String -> String

def lit_ci source · line 145 · 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 149 · raw

@s:String -> Bool

def trim_sp source · line 152 · raw

@s:String -> String

def has_ci source · line 156 · raw

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

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

def esc.pick source · line 161 · raw

@amp:Bool -> @lt:Bool -> @gt:Bool -> @quot:Bool -> @c:Char -> @rest:String -> String

def esc source · line 180 · raw

@s:String -> String

def hexd source · line 188 · raw

@+n:U32 -> U32

def pct source · line 191 · raw

@+b:U32 -> String

def pct_utf8 source · line 195 · raw

@+c:U32 -> String

Each UTF-8 octet of c as %XX.

def href_safe source · line 202 · raw

@+c:U32 -> Bool

def href.pick source · line 205 · raw

@amp:Bool -> @apos:Bool -> @safe:Bool -> @+c:U32 -> @rest:String -> String

def href source · line 221 · raw

@s:String -> String

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

def num.dec source · line 231 · raw

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

def hexv source · line 238 · raw

@+c:U32 -> U32

def num.hex source · line 241 · raw

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

def cp_ok source · line 248 · raw

@+n:U32 -> U32

def ent.num source · line 251 · raw

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

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

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

def ent.named source · line 262 · raw

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

def ent.hash source · line 266 · raw

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

def ent.hex source · line 270 · raw

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

def ent.sharp source · line 274 · raw

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

def ent.pick source · line 278 · raw

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

def ent source · line 286 · raw

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

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

def unesc.ent source · line 291 · raw

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

def unesc.amp source · line 298 · raw

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

def unesc.step source · line 306 · 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 309 · raw

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

def unesc.go source · line 316 · raw

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

def unesc source · line 330 · raw

@+s:String -> String

Backslash escapes and character references resolved.

def ch source · line 342 · raw

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

def esc_ch source · line 350 · raw

@+c:U32 -> Ch

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

def label.go source · line 353 · raw

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

def label.ok source · line 368 · raw

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

def label source · line 376 · 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 379 · raw

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

def dk source · line 405 · raw

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

def dest.go source · line 411 · raw

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

def dest.plain source · line 428 · raw

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

def dest.pick source · line 434 · raw

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

def dest source · line 443 · raw

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

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

def title.go source · line 446 · raw

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

def title.of source · line 465 · raw

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

def title source · line 472 · raw

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

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

def ws1 source · line 477 · raw

@+s:String -> String

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

def eol source · line 482 · 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 494 · raw

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

def norm source · line 503 · raw

@s:String -> String

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

def alt source · line 506 · raw

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

def refdef.title source · line 513 · raw

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

def refdef.titled source · line 520 · raw

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

def refdef.bare source · line 527 · raw

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

def refdef.dest source · line 532 · raw

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

def refdef.label source · line 537 · raw

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

def refdef source · line 547 · raw

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

A link reference definition at the start of s.

def cut.go source · line 556 · raw

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

def cut source · line 568 · raw

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

The text after the first pat in s.

def is_wsn source · line 571 · raw

@+c:U32 -> Bool

def wsp source · line 574 · raw

@+s:String -> String

def need source · line 577 · raw

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

def tagname source · line 580 · raw

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

def attrname source · line 583 · raw

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

def unquoted source · line 587 · raw

@+c:U32 -> Bool

def attrval source · line 590 · raw

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

def or source · line 595 · raw

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

def attr.value source · line 602 · raw

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

def attr source · line 608 · raw

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

def attrs.go source · line 614 · raw

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

def attrs source · line 625 · raw

@+s:String -> String

def open_tag source · line 628 · raw

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

def close_tag source · line 636 · raw

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

def comment source · line 643 · raw

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

def decl source · line 649 · raw

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

def cut.after source · line 656 · raw

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

def raw_html source · line 664 · raw

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

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

def same_kind source · line 709 · raw

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

def is_ord source · line 718 · raw

@k:Mark -> Bool

def ends source · line 726 · 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 739 · raw

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

def loose source · line 746 · raw

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

def g_flush source · line 759 · raw

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

def g_same source · line 769 · raw

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

def group.item source · line 774 · raw

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

def group.step source · line 783 · raw

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

def group.go source · line 790 · raw

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

def group source · line 798 · raw

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

Runs of items of one kind become lists.

def push_kid source · line 801 · raw

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

def add_kid source · line 810 · raw

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

def join_rev source · line 817 · raw

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

def drop_blank_lines source · line 820 · raw

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

def has_ref source · line 827 · raw

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

def add_ref source · line 835 · raw

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

The first definition of a label wins.

def defs.go source · line 840 · raw

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

def defs source · line 852 · 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 855 · raw

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

def fence.body source · line 859 · raw

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

def close_leaf source · line 862 · raw

@st:St -> St

def frame_kid source · line 877 · raw

@f:Frame -> Kid

def close_frame source · line 887 · raw

@st:St -> St

Closes the innermost container; its leaf must be closed.

def pop source · line 896 · raw

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

def ln_s source · line 905 · raw

@ln:Ln -> String

def ln_col source · line 910 · raw

@ln:Ln -> U32

def tabw source · line 915 · raw

@+col:U32 -> U32

def adv.w source · line 918 · raw

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

def adv.go source · line 922 · 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 940 · 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 945 · raw

@ln:Ln -> Ln

def cx source · line 952 · raw

@+ln:Ln -> Cx

def cx_ln source · line 956 · raw

@c:Cx -> Ln

def cx_at source · line 961 · raw

@c:Cx -> Ln

def cx_ind source · line 966 · raw

@c:Cx -> U32

def cx_blank source · line 971 · raw

@c:Cx -> Bool

def atx.text source · line 981 · raw

@+t:String -> String

def atx.of source · line 986 · raw

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

def atx source · line 989 · raw

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

def fence source · line 996 · raw

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

def close_fence source · line 1002 · raw

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

def hr.go source · line 1006 · raw

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

def hr source · line 1013 · raw

@+s:String -> Bool

def setext source · line 1018 · raw

@+s:String -> U32

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

def item.ord source · line 1027 · raw

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

def item.of source · line 1033 · raw

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

def item.scan source · line 1037 · raw

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

def blocknames source · line 1042 · raw

List<&2, String>

def member source · line 1045 · raw

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

def html6 source · line 1052 · raw

@+s:String -> Bool

def html1.one source · line 1058 · raw

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

def html1 source · line 1066 · raw

@+s:String -> Bool

def html7.ok source · line 1069 · raw

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

def html_start.lt source · line 1076 · raw

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

def html_start source · line 1090 · 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 1093 · raw

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

def after_gt source · line 1102 · raw

@at:Ln -> Ln

def quote_cont source · line 1107 · raw

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

def item_cont source · line 1112 · raw

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

def cont source · line 1118 · 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 1130 · raw

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

def walk source · line 1138 · 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 1155 · raw

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

def p_ln source · line 1191 · raw

@p:P -> Ln

def p_tipp source · line 1196 · raw

@p:P -> Bool

def p_cpara source · line 1201 · raw

@p:P -> Bool

def p_line source · line 1210 · raw

@p:P -> U32

def push_frame source · line 1215 · raw

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

def set_leaf source · line 1220 · raw

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

def add_kid_st source · line 1225 · raw

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

def unmatched source · line 1231 · raw

@p:P -> P

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

def prep.go source · line 1240 · raw

@p:P -> St

def prep source · line 1246 · raw

@p:P -> St

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

def try.code source · line 1249 · raw

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

def item.open source · line 1254 · raw

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

def try.item source · line 1266 · raw

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

def try.hr source · line 1273 · raw

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

def setext.close source · line 1280 · raw

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

def setext.apply source · line 1284 · raw

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

def try.setext source · line 1293 · raw

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

def html.open source · line 1300 · raw

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

def try.html source · line 1305 · raw

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

def try.fence source · line 1309 · raw

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

def try.atx source · line 1316 · raw

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

def try.quote source · line 1323 · raw

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

def starts.try source · line 1330 · raw

@+p:P -> Sr

def starts.go source · line 1334 · raw

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

def f_reset source · line 1347 · raw

@f:Frame -> Frame

def reset_all source · line 1356 · raw

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

def kid_blank source · line 1363 · raw

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

def f_blank source · line 1371 · 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 1380 · raw

@st:St -> St

def head_blank source · line 1385 · raw

@st:St -> St

def leaf_llb source · line 1394 · raw

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

def st_leaf source · line 1405 · raw

@st:St -> Leaf

def leaf_none source · line 1410 · raw

@leaf:Leaf -> Bool

def leaf_para source · line 1417 · raw

@leaf:Leaf -> Bool

def leaf_add source · line 1424 · raw

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

def text.put source · line 1440 · raw

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

def text.lazy source · line 1451 · raw

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

def text.add source · line 1461 · 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 1469 · raw

@r:Sr -> St

def line.run source · line 1478 · raw

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

def line.lm source · line 1481 · raw

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

def line.pops source · line 1492 · raw

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

def line.walked source · line 1499 · raw

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

def line source · line 1505 · raw

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

def doc.go source · line 1513 · raw

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

def finish.doc source · line 1520 · raw

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

def finish source · line 1529 · raw

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

def clean source · line 1534 · raw

@s:String -> String

def drop_cr source · line 1541 · raw

@+l:String -> String

def lines.go source · line 1544 · raw

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

def blocks source · line 1554 · 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 1566 · raw

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

def r.inl source · line 1569 · raw

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

def p.inl source · line 1582 · raw

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

def odd_fail source · line 1607 · 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 1610 · raw

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

def rs.of source · line 1620 · raw

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

def seek source · line 1627 · raw

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

def wrap source · line 1634 · raw

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

def keep source · line 1639 · raw

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

def resolve source · line 1643 · 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 1659 · raw

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

def emph.go source · line 1666 · raw

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

def emph source · line 1676 · raw

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

Emphasis and strong emphasis, by the delimiter run rules.

def flush source · line 1684 · raw

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

def tick.go source · line 1687 · raw

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

def cnl source · line 1703 · raw

@s:String -> String

def cnorm source · line 1711 · 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 1715 · raw

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

def code source · line 1723 · raw

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

def scheme_ch source · line 1728 · raw

@+c:U32 -> Bool

def uri_ch source · line 1731 · raw

@+c:U32 -> Bool

def auto.uri source · line 1734 · raw

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

def email_ch source · line 1742 · raw

@+c:U32 -> Bool

def dom_ch source · line 1745 · raw

@+c:U32 -> Bool

def dom.parts source · line 1748 · raw

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

def dom_ok source · line 1756 · raw

@+d:String -> Bool

def auto.email source · line 1760 · raw

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

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

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

def url.has source · line 1774 · raw

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

def url.bad source · line 1778 · raw

@+s:String -> Bool

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

def url source · line 1783 · raw

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

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

def o.safe source · line 1794 · raw

@o:Opts -> Bool

def o.gfm source · line 1799 · raw

@o:Opts -> Bool

def tagf.end source · line 1804 · raw

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

def tagf.name source · line 1812 · raw

@+n:String -> @+a:String -> Bool

def tagf.bad source · line 1816 · raw

@+s:String -> Bool

s follows a <. GFM's tag filter blocks these nine tags, open or closed.

def tagf.lt source · line 1820 · raw

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

def tagfilter source · line 1827 · raw

@s:String -> String

def html_out source · line 1836 · raw

@o:Opts -> @+raw:String -> String

Raw HTML as the options render it.

def lt.html source · line 1849 · raw

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

def lt.email source · line 1857 · raw

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

def lt.uri source · line 1864 · raw

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

def amp.got source · line 1871 · raw

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

def nl source · line 1879 · 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 1884 · raw

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

def delim source · line 1890 · raw

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

def al.bound source · line 1905 · raw

@+c:U32 -> Bool

A code point after which an extended autolink may start.

def al.space source · line 1908 · raw

@+c:U32 -> Bool

def al.host source · line 1911 · raw

@+c:U32 -> Bool

def al.cnt source · line 1914 · raw

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

def al.last2 source · line 1921 · raw

@xs:List<&2, String> -> @+a:String -> @+b:String -> Pair(String, String)

def al.dom.of source · line 1928 · raw

@+run:String -> @+allow_short:Bool -> @p:Pair(String, String) -> Nat

def al.dom.run source · line 1934 · raw

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

def al.dom source · line 1939 · raw

@+s:String -> @+allow_short:Bool -> Nat

cmark-gfm's check_domain: the length of the domain at s, or 0. It never looks at the last code point of s.

def al.k source · line 1949 · raw

@+c:U32 -> Ak

def al.semi source · line 1954 · raw

@+t:String -> String

def al.trim source · line 1959 · raw

@f:Nat -> @k:Ak -> @+rs:String -> @+closing:Nat -> @+opening:Nat -> String

cmark-gfm's autolink_delim over the link reversed: trailing punctuation, unbalanced ) and a trailing entity drop off.

def al.delim source · line 1977 · raw

@+link:String -> String

def al.tail source · line 1989 · raw

@+pre:String -> @+d:Nat -> @+s:String -> Maybe<&2, Al>

The domain is d long; the link runs to the next space, then loses its trailing punctuation.

def al.www source · line 1993 · raw

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

def al.scheme.of source · line 1996 · raw

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

def al.scheme source · line 2005 · raw

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

def al.mail_ch source · line 2008 · raw

@+c:U32 -> Bool

def al.dpart.ok source · line 2011 · raw

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

def al.dpart.go source · line 2014 · raw

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

def al.dpart source · line 2026 · raw

@+s:String -> String

The domain of an email after its @, as cmark-gfm's email_match scans it.

def al.mail source · line 2029 · raw

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

def al.or source · line 2036 · raw

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

def al source · line 2044 · raw

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

A GFM extended autolink at the start of s: www., http://, https://, ftp://, or an email address.

def other.al source · line 2047 · raw

@m:Maybe<&2, Al> -> @+y:U32 -> @+t:String -> @+buf:String -> @out:List<&2, Inl> -> @+safe:Bool -> Is

def other source · line 2054 · raw

@try:Bool -> @+y:U32 -> @+t:String -> @+buf:String -> @out:List<&2, Inl> -> @+o:Opts -> Is

def brk source · line 2067 · raw

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

def deact source · line 2076 · raw

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

def find_ref source · line 2088 · raw

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

def lookup.got source · line 2095 · raw

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

def lookup source · line 2102 · raw

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

def ref.full source · line 2105 · raw

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

def ref.tail source · line 2112 · raw

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

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

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

def inl.close source · line 2122 · raw

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

def inl.title source · line 2127 · raw

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

def inl.dest source · line 2133 · raw

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

def inl.got source · line 2137 · raw

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

def inl.open source · line 2144 · raw

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

def inl.tail source · line 2148 · raw

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

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

def lt_or source · line 2151 · raw

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

def title_attr source · line 2158 · raw

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

def link.make source · line 2165 · raw

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

def link.fail source · line 2175 · raw

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

def link.try source · line 2178 · raw

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

def close.br source · line 2185 · raw

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

def ic source · line 2211 · raw

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

def istep source · line 2222 · raw

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

def inl.go source · line 2245 · raw

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

def inline source · line 2259 · raw

@+s:String -> @+refs:List<&2, Ref> -> @+o:Opts -> String

A paragraph or heading's text as HTML.

def cr source · line 2264 · raw

@+out:String -> String

def put source · line 2267 · raw

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

def code_open source · line 2270 · raw

@+info:String -> String

def list_open source · line 2274 · raw

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

def tbl.join source · line 2280 · raw

@xs:List<&2, String> -> @+cur:String -> @+acc:List<&2, String> -> List<&2, String>

Pieces split at every |; a piece that ends in an odd run of \ joins the next one, its \ dropped.

def tbl.cells.of source · line 2289 · raw

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

def tbl.cells source · line 2297 · raw

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

A table row's cells, trimmed, with its outer pipes dropped and \| as |.

def tbl.dcell source · line 2304 · raw

@+c:String -> Bool

def tbl.drow source · line 2310 · raw

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

def tbl.align source · line 2317 · raw

@+c:String -> String

def tbl.aligns source · line 2322 · raw

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

def tbl.find source · line 2333 · raw

@ls:List<&2, String> -> @+before:List<&2, String> -> Maybe<&2, Tb>

def tbl.row source · line 2348 · raw

@aligns:List<&2, String> -> @cs:List<&2, String> -> @+tag:String -> @+refs:List<&2, Ref> -> @+o:Opts -> String

One row's cells, cut or padded with empty cells to the header's width.

def tbl.rows source · line 2357 · raw

@rows:List<&2, String> -> @+aligns:List<&2, String> -> @+refs:List<&2, Ref> -> @+o:Opts -> String

def tbl.html source · line 2364 · raw

@+head:List<&2, String> -> @+aligns:List<&2, String> -> @+rows:List<&2, String> -> @+refs:List<&2, Ref> -> @+o:Opts -> String

def r.text source · line 2369 · raw

@+t:String -> @+tight:Bool -> @+refs:List<&2, Ref> -> @+o:Opts -> @+pre:String -> @+out:String -> String

A paragraph's text, after pre, in <p> unless tight.

def r.tbl source · line 2373 · raw

@m:Maybe<&2, Tb> -> @+t:String -> @+tight:Bool -> @+refs:List<&2, Ref> -> @+o:Opts -> @+out:String -> String

def r.para source · line 2381 · raw

@gfm:Bool -> @+t:String -> @+tight:Bool -> @+refs:List<&2, Ref> -> @+o:Opts -> @+out:String -> String

def task.kind source · line 2389 · raw

@+gfm:Bool -> @+t:String -> U32

A GFM task list item's first paragraph: 0 for none, 1 for [ ], 2 for [x] or [X].

def r.first source · line 2394 · raw

@task:Bool -> @+k:U32 -> @+t:String -> @+tight:Bool -> @+refs:List<&2, Ref> -> @+o:Opts -> @+out:String -> String

def r.go source · line 2402 · raw

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

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

def render source · line 2427 · raw

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

def to_html_with source · line 2432 · raw

@o:Opts -> @s:String -> String

Markdown to HTML with options: o.safe for untrusted input, o.gfm for GitHub tables, task lists, strikethrough, extended autolinks, and the tag filter.

def to_html source · line 2436 · raw

@s:String -> String

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

def to_html_safe source · line 2440 · 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 101 · raw

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

template span source · line 113 · 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 116 · raw

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