markdown.bend checks
raw source on the hub · import bend-kit-markdown@0.3.8.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.
Got@v:String -> @rest:String -> Got
type Ch source · line 334 · raw
Data
A scanner's view of the next code point.
CEndCh
CBsCh
COpenCh
CCloseCh
CNlCh
COtherCh
type Dk source · line 398 · raw
Data
DStopDk
DOpenDk
DDecDk
DBsDk
DOtherDk
type Ref source · line 487 · raw
Data
Ref@label:String -> @dest:String -> @title:Maybe<&2, String> -> Ref
type RefGot source · line 491 · raw
Data
A parsed definition and the text after it.
RefGot@ref:Ref -> @rest:String -> RefGot
type Ms source · line 670 · raw
Data
The closers that an earlier < showed are missing from the rest of the paragraph: -->, ?>, ]]>, and the > of a declaration.
Ms@com:Bool -> @pi:Bool -> @cd:Bool -> @dec:Bool -> Ms
type Mark source · line 712 · raw
Data
KBul@c:U32 -> Mark
KOrd@d:U32 -> Mark
type Kid source · line 717 · raw
Data
A block and whether the last line it took was blank, for tight and loose lists.
Kid@llb:Bool -> @b:Block -> Kid
type Block source · line 720 · raw
Data
BPara@text:String -> Block
BHead@lv:U32 -> @text:String -> Block
BCode@info:String -> @text:String -> Block
BHtml@text:String -> Block
BRuleBlock
BQuote@kids:List<&2, Kid> -> Block
BItem@kind:Mark -> @start:U32 -> @kids:List<&2, Kid> -> Block
BList@ord:Bool -> @start:U32 -> @tight:Bool -> @items:List<&2, Kid> -> Block
type Frame source · line 731 · raw
Data
An open container. kids are newest first.
FDoc@kids:List<&2, Kid> -> Frame
FQuote@llb:Bool -> @kids:List<&2, Kid> -> Frame
FItem@llb:Bool -> @kind:Mark -> @start:U32 -> @pad:U32 -> @line0:U32 -> @kids:List<&2, Kid> -> Frame
type Leaf source · line 737 · raw
Data
The open leaf of the innermost container. lines are newest first.
LNoneLeaf
LPara@llb:Bool -> @lines:List<&2, String> -> Leaf
LCode@llb:Bool -> @lines:List<&2, String> -> Leaf
LFence@c:U32 -> @n:U32 -> @ind:U32 -> @info:String -> @lines:List<&2, String> -> Leaf
LHtml@kind:U32 -> @lines:List<&2, String> -> Leaf
type St source · line 745 · raw
Data
The parser between lines. stack is innermost first and ends with FDoc.
St@stack:List<&2, Frame> -> @leaf:Leaf -> @refs:List<&2, Ref> -> @line:U32 -> St
type Ln source · line 749 · raw
Data
The rest of a line and the column it starts at.
Ln@s:String -> @col:U32 -> Ln
type G source · line 799 · raw
Data
G@has:Bool -> @kind:Mark -> @start:U32 -> @items:List<&2, Kid> -> @out:List<&2, Kid> -> G
type Cx source · line 992 · raw
Data
A line at the current container: the line, the line at its first non-space, the indent in columns, and blankness.
Cx@ln:Ln -> @at:Ln -> @ind:U32 -> @blank:Bool -> Cx
type Hd source · line 1021 · raw
Data
Hd@lv:U32 -> @text:String -> Hd
type Fg source · line 1036 · raw
Data
Fg@c:U32 -> @n:U32 -> @info:String -> Fg
type Im source · line 1067 · raw
Data
A list marker: its kind, start number, and width in characters.
Im@kind:Mark -> @start:U32 -> @w:U32 -> Im
type W source · line 1170 · raw
Data
W@k:Nat -> @ln:Ln -> W
type Lm source · line 1192 · raw
Data
LmNoLm
LmParaLm
LmLeaf@ln:Ln -> Lm
LmEndLm
type Lk source · line 1219 · raw
Data
LkNoneLk
LkParaLk
LkLeafLk
LkUnLk
type P source · line 1226 · raw
Data
A line in progress. pops counts the containers it did not continue. tipp: the leaf was a paragraph when the line began.
P@st:St -> @ln:Ln -> @pops:Nat -> @lk:Lk -> @tipp:Bool -> P
type Sr source · line 1229 · raw
Data
SCont@p:P -> Sr
SStop@p:P -> Sr
SDone@st:St -> Sr
type Inl source · line 1603 · raw
Data
An inline in progress. IHtml is finished output and its plain text, for image alt text. IMark renders as nothing; no active link bracket lies below it.
IText@s:String -> Inl
IHtml@html:String -> @plain:String -> Inl
IDelim@c:U32 -> @n:U32 -> @orig:U32 -> @open:Bool -> @close:Bool -> Inl
IBrack@img:Bool -> @active:Bool -> @after:String -> @ms:Ms -> Inl
IMarkInl
type Fd source · line 1646 · raw
Data
A matching opener: the inlines after it (oldest first), the opener, the height of the stack below it, and that stack.
Fd@above:List<&2, Inl> -> @c:U32 -> @n:U32 -> @o:U32 -> @op:Bool -> @cl:Bool -> @hb:Nat -> @below:List<&2, Inl> -> Fd
type Rs source · line 1649 · raw
Data
RDoneRs
RNoneRs
RFound@fd:Fd -> Rs
type Bot source · line 1655 · raw
Data
A closer kind's openers_bottom, as in the CommonMark reference: the bottom h inlines of the stack hold no opener for it.
Bot@k:U32 -> @h:Nat -> Bot
type Em source · line 1659 · raw
Data
The emphasis stack, newest first, its height, and the bottom of each closer kind.
Em@stack:List<&2, Inl> -> @h:Nat -> @bots:List<&2, Bot> -> Em
type Is source · line 1777 · raw
Data
Is@s:String -> @prev:U32 -> @buf:String -> @out:List<&2, Inl> -> Is
type Opts source · line 1887 · raw
Data
Render options. safe renders as cmark without --unsafe. gfm turns on the GitHub extensions.
Opts@safe:Bool -> @gfm:Bool -> Opts
type Ak source · line 2039 · raw
Data
AkStopAk
AkParenAk
AkPunctAk
AkSemiAk
type Al source · line 2078 · raw
Data
Al@href:String -> @text:String -> Al
type Bk source · line 2159 · raw
Data
Splits the output at its newest bracket: the inlines after it (oldest first), the bracket, and the rest.
Bk@above:List<&2, Inl> -> @img:Bool -> @active:Bool -> @after:String -> @ms:Ms -> @below:List<&2, Inl> -> Bk
type Lt source · line 2185 · raw
Data
Lt@dest:String -> @title:Maybe<&2, String> -> @rest:String -> Lt
type Ic source · line 2362 · raw
Data
IcBsIc
IcTickIc
IcStarIc
IcOpenIc
IcBangIc
IcCloseIc
IcLtIc
IcAmpIc
IcNlIc
IcOtherIc
type Tb source · line 2517 · raw
Data
A table in a paragraph: the lines before its header row, the header cells, the alignments, and the body rows.
Tb@before:List<&2, String> -> @head:List<&2, String> -> @aligns:List<&2, String> -> @rows:List<&2, String> -> Tb
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 -> @+n:Nat -> Maybe<&2, Nat>
def cut source · line 568 · raw
@+s:String -> @+pat:String -> Maybe<&2, Nat>
The length of s up to and through the first pat.
def is_wsn source · line 571 · raw
@+c:U32 -> Bool
def wsp source · line 574 · raw
@+s:String -> String
def wsn source · line 581 · raw
@+s:String -> Nat
def need source · line 584 · raw
@ok:Bool -> @+n:Nat -> Maybe<&2, Nat>
def tok source · line 587 · raw
@+p:String -> @+s:String -> Maybe<&2, Nat>
def add source · line 590 · raw
@+a:Nat -> @m:Maybe<&2, Nat> -> Maybe<&2, Nat>
def tagname source · line 597 · raw
@+s:String -> Maybe<&2, Nat>
def attrname source · line 600 · raw
@+s:String -> Maybe<&2, Nat>
def unquoted source · line 604 · raw
@+c:U32 -> Bool
def attrval source · line 607 · raw
@+s:String -> Maybe<&2, Nat>
def or source · line 612 · raw
@a:Maybe<&2, Nat> -> @b:Maybe<&2, Nat> -> Maybe<&2, Nat>
def attr.value source · line 619 · raw
@+s:String -> Maybe<&2, Nat>
def attr source · line 628 · raw
@+s:String -> Maybe<&2, Nat>
def attrs.go source · line 635 · raw
@f:String -> @m:Maybe<&2, Nat> -> @+s:String -> @+n:Nat -> Nat
def attrs source · line 648 · raw
@+s:String -> Nat
Each attribute takes at least one code point, so s itself is enough fuel.
def open_tag source · line 651 · raw
@+s:String -> Maybe<&2, Nat>
def close_tag source · line 661 · raw
@+s:String -> Maybe<&2, Nat>
def cut.if source · line 674 · raw
@no:Bool -> @+s:String -> @+pat:String -> Maybe<&2, Nat>
cut, unless pat is known to be missing.
def comment source · line 677 · raw
@+no:Bool -> @+s:String -> Maybe<&2, Nat>
def decl source · line 684 · raw
@+no:Bool -> @+s:String -> Maybe<&2, Nat>
def cut.after source · line 691 · raw
@+no:Bool -> @+p:String -> @+s:String -> @+pat:String -> Maybe<&2, Nat>
def raw_html source · line 699 · raw
@ms:Ms -> @+s:String -> Maybe<&2, Nat>
The length of the raw inline HTML at the start of s.
def ms.add source · line 705 · raw
@+t:String -> @m:Ms -> Ms
After a < at t that was not inline HTML: the closer it scanned for is missing from the rest.
def same_kind source · line 752 · raw
@a:Mark -> @b:Mark -> Bool
def is_ord source · line 761 · raw
@k:Mark -> Bool
def ends source · line 769 · 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 782 · raw
@ks:List<&2, Kid> -> @+next:Bool -> Bool
def loose source · line 789 · raw
@items:List<&2, Kid> -> Bool
def g_flush source · line 802 · raw
@g:G -> List<&2, Kid>
def g_same source · line 812 · raw
@g:G -> @k:Mark -> Bool
def group.item source · line 817 · raw
@same:Bool -> @g:G -> @+k:Kid -> @+kind:Mark -> @+start:U32 -> G
def group.step source · line 826 · raw
@+g:G -> @k:Kid -> G
def group.go source · line 833 · raw
@ks:List<&2, Kid> -> @+g:G -> List<&2, Kid>
def group source · line 841 · raw
@ks:List<&2, Kid> -> List<&2, Kid>
Runs of items of one kind become lists.
def push_kid source · line 844 · raw
@f:Frame -> @k:Kid -> Frame
def add_kid source · line 853 · raw
@stack:List<&2, Frame> -> @k:Kid -> List<&2, Frame>
def join_rev source · line 860 · raw
@lines:List<&2, String> -> String
def drop_blank_lines source · line 863 · raw
@lines:List<&2, String> -> List<&2, String>
def has_ref source · line 870 · raw
@refs:List<&2, Ref> -> @+label:String -> Bool
def add_ref source · line 878 · raw
@+refs:List<&2, Ref> -> @r:Ref -> List<&2, Ref>
The first definition of a label wins.
def defs.go source · line 883 · raw
@f:Nat -> @m:Maybe<&2, RefGot> -> @+s:String -> @+refs:List<&2, Ref> -> Pair(String, List<&2, Ref>)
def defs source · line 895 · 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 898 · raw
@+llb:Bool -> @r:Pair(String, List<&2, Ref>) -> @+stack:List<&2, Frame> -> @+line:U32 -> St
def fence.body source · line 902 · raw
@+lines:List<&2, String> -> String
def close_leaf source · line 905 · raw
@st:St -> St
def frame_kid source · line 920 · raw
@f:Frame -> Kid
def close_frame source · line 930 · raw
@st:St -> St
Closes the innermost container; its leaf must be closed.
def pop source · line 939 · raw
@n:Nat -> @st:St -> St
def ln_s source · line 948 · raw
@ln:Ln -> String
def ln_col source · line 953 · raw
@ln:Ln -> U32
def tabw source · line 958 · raw
@+col:U32 -> U32
def adv.w source · line 961 · raw
@+c:U32 -> @+col:U32 -> U32
def adv.go source · line 965 · 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 983 · 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 988 · raw
@ln:Ln -> Ln
def cx source · line 995 · raw
@+ln:Ln -> Cx
def cx_ln source · line 999 · raw
@c:Cx -> Ln
def cx_at source · line 1004 · raw
@c:Cx -> Ln
def cx_ind source · line 1009 · raw
@c:Cx -> U32
def cx_blank source · line 1014 · raw
@c:Cx -> Bool
def atx.text source · line 1024 · raw
@+t:String -> String
def atx.of source · line 1029 · raw
@+n:Nat -> @+r:String -> Maybe<&2, Hd>
def atx source · line 1032 · raw
@+s:String -> Maybe<&2, Hd>
def fence source · line 1039 · raw
@+s:String -> Maybe<&2, Fg>
def close_fence source · line 1045 · raw
@+s:String -> @+c:U32 -> @+n:U32 -> Bool
def hr.go source · line 1049 · raw
@s:String -> @+c:U32 -> @+n:Nat -> Bool
def hr source · line 1056 · raw
@+s:String -> Bool
def setext source · line 1061 · raw
@+s:String -> U32
1 for a = underline, 2 for -, 0 for neither.
def item.ord source · line 1070 · raw
@+d:String -> @+r:String -> Maybe<&2, Im>
def item.of source · line 1076 · raw
@r:Pair(String, String) -> Maybe<&2, Im>
def item.scan source · line 1080 · raw
@+s:String -> Maybe<&2, Im>
def blocknames source · line 1085 · raw
List<&2, String>
def member source · line 1088 · raw
@xs:List<&2, String> -> @+n:String -> Bool
def html6 source · line 1095 · raw
@+s:String -> Bool
def html1.one source · line 1101 · raw
@m:Maybe<&2, String> -> Bool
def html1 source · line 1109 · raw
@+s:String -> Bool
def html7.ok source · line 1112 · raw
@m:Maybe<&2, Nat> -> @+s:String -> Bool
def html_start.lt source · line 1119 · raw
@lt:Bool -> @+s:String -> @+cpara:Bool -> U32
def html_start source · line 1133 · 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 1136 · raw
@+k:U32 -> @+s:String -> Bool
def after_gt source · line 1145 · raw
@at:Ln -> Ln
def quote_cont source · line 1150 · raw
@c:Cx -> Maybe<&2, Ln>
def item_cont source · line 1155 · raw
@+hc:Bool -> @+pad:U32 -> @c:Cx -> Maybe<&2, Ln>
def cont source · line 1161 · 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 1173 · raw
@frames:List<&2, Frame> -> @+ln:Ln -> @+leafnone:Bool -> Maybe<&2, Ln>
def walk source · line 1181 · 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 1198 · raw
@leaf:Leaf -> @c:Cx -> Lm
def p_ln source · line 1234 · raw
@p:P -> Ln
def p_tipp source · line 1239 · raw
@p:P -> Bool
def p_cpara source · line 1244 · raw
@p:P -> Bool
def p_line source · line 1253 · raw
@p:P -> U32
def push_frame source · line 1258 · raw
@st:St -> @f:Frame -> St
def set_leaf source · line 1263 · raw
@st:St -> @leaf:Leaf -> St
def add_kid_st source · line 1268 · raw
@st:St -> @k:Kid -> St
def unmatched source · line 1274 · raw
@p:P -> P
Closes the containers, and the leaf, that the line did not continue.
def prep.go source · line 1283 · raw
@p:P -> St
def prep source · line 1289 · raw
@p:P -> St
Ready for a new block: unmatched blocks closed, and the leaf closed.
def try.code source · line 1292 · raw
@+p:P -> @c:Cx -> Sr
def item.open source · line 1297 · raw
@im:Im -> @+p:P -> @+c:Cx -> Sr
def try.item source · line 1309 · raw
@m:Maybe<&2, Im> -> @+p:P -> @+c:Cx -> Sr
def try.hr source · line 1316 · raw
@ok:Bool -> @+p:P -> @+c:Cx -> Sr
def setext.close source · line 1323 · raw
@+lv:U32 -> @r:Pair(String, List<&2, Ref>) -> @+stack:List<&2, Frame> -> @+line:U32 -> @+p:P -> Sr
def setext.apply source · line 1327 · raw
@+lv:U32 -> @+p:P -> Sr
def try.setext source · line 1336 · raw
@ok:Bool -> @+lv:U32 -> @+p:P -> @+c:Cx -> Sr
def html.open source · line 1343 · raw
@+k:U32 -> @+p:P -> @+c:Cx -> Sr
def try.html source · line 1348 · raw
@+k:U32 -> @+p:P -> @+c:Cx -> Sr
def try.fence source · line 1352 · raw
@m:Maybe<&2, Fg> -> @+p:P -> @+c:Cx -> Sr
def try.atx source · line 1359 · raw
@m:Maybe<&2, Hd> -> @+p:P -> @+c:Cx -> Sr
def try.quote source · line 1366 · raw
@ok:Bool -> @+p:P -> @+c:Cx -> Sr
def starts.try source · line 1373 · raw
@+p:P -> Sr
def starts.go source · line 1377 · raw
@f:Nat -> @r:Sr -> Sr
def f_reset source · line 1390 · raw
@f:Frame -> Frame
def reset_all source · line 1399 · raw
@stack:List<&2, Frame> -> List<&2, Frame>
def kid_blank source · line 1406 · raw
@ks:List<&2, Kid> -> List<&2, Kid>
def f_blank source · line 1414 · 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 1423 · raw
@st:St -> St
def head_blank source · line 1428 · raw
@st:St -> St
def leaf_llb source · line 1437 · raw
@st:St -> @+blank:Bool -> St
def st_leaf source · line 1448 · raw
@st:St -> Leaf
def leaf_none source · line 1453 · raw
@leaf:Leaf -> Bool
def leaf_para source · line 1460 · raw
@leaf:Leaf -> Bool
def leaf_add source · line 1467 · raw
@st:St -> @+s:String -> St
def text.put source · line 1483 · raw
@p:P -> @+c:Cx -> St
def text.lazy source · line 1494 · raw
@lazy:Bool -> @+p:P -> @+c:Cx -> St
def text.add source · line 1504 · 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 1512 · raw
@r:Sr -> St
def line.run source · line 1521 · raw
@p:P -> @+ln:Ln -> St
def line.lm source · line 1524 · raw
@m:Lm -> @+st:St -> @+ln:Ln -> @+tipp:Bool -> St
def line.pops source · line 1535 · raw
@un:Bool -> @+pops:Nat -> @+st:St -> @+ln:Ln -> @+tipp:Bool -> St
def line.walked source · line 1542 · raw
@w:W -> @+st:St -> @+depth:Nat -> @+tipp:Bool -> St
def line source · line 1548 · raw
@st:St -> @raw:String -> St
def doc.go source · line 1556 · raw
@lines:List<&2, String> -> @st:St -> St
def finish.doc source · line 1563 · raw
@st:St -> Pair(List<&2, Kid>, List<&2, Ref>)
def finish source · line 1572 · raw
@st:St -> Pair(List<&2, Kid>, List<&2, Ref>)
def clean source · line 1577 · raw
@s:String -> String
def drop_cr source · line 1584 · raw
@+l:String -> String
def lines.go source · line 1587 · raw
@xs:List<&2, String> -> List<&2, String>
def blocks source · line 1597 · 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 1610 · raw
@+c:U32 -> @n:U32 -> String
def r.inl source · line 1613 · raw
@xs:List<&2, Inl> -> String
def p.inl source · line 1628 · raw
@xs:List<&2, Inl> -> String
def bot.key source · line 1663 · raw
@+c:U32 -> @+copen:Bool -> @+orig:U32 -> U32
Whether an opener fits a closer depends only on its character, whether it can open, and its length mod 3.
def bot.get source · line 1666 · raw
@bs:List<&2, Bot> -> @+k:U32 -> Nat
def bot.put source · line 1673 · raw
@bs:List<&2, Bot> -> @+k:U32 -> @+h:Nat -> List<&2, Bot>
def bot.clamp source · line 1680 · raw
@bs:List<&2, Bot> -> @+h:Nat -> List<&2, Bot>
def odd_fail source · line 1688 · 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 1692 · raw
@stack:List<&2, Inl> -> @+h:Nat -> @+bot:Nat -> @+c:U32 -> @+orig:U32 -> @+copen:Bool -> @+acc:List<&2, Inl> -> Maybe<&2, Fd>
Searches the stack, h high, for an opener above its bottom bot.
def rs.of source · line 1704 · raw
@m:Maybe<&2, Fd> -> Rs
def seek source · line 1711 · raw
@more:Bool -> @+stack:List<&2, Inl> -> @+h:Nat -> @+bots:List<&2, Bot> -> @+c:U32 -> @+orig:U32 -> @+copen:Bool -> Rs
def wrap source · line 1718 · raw
@+c:U32 -> @+use:U32 -> @+xs:List<&2, Inl> -> Inl
def keep source · line 1723 · raw
@+n:U32 -> @+c:U32 -> @+o:U32 -> @+op:Bool -> @+cl:Bool -> @+below:List<&2, Inl> -> List<&2, Inl>
def resolve source · line 1727 · raw
@f:Nat -> @r:Rs -> @+stack:List<&2, Inl> -> @+h:Nat -> @+bots:List<&2, Bot> -> @+c:U32 -> @+n:U32 -> @+orig:U32 -> @+copen:Bool -> Em
Matches the closer, n long, against openers until it runs out or none is left. A miss raises the closer kind's bottom to the stack top; a match lowers every bottom to the new top.
def emph.delim source · line 1747 · raw
@cl:Bool -> @em:Em -> @+c:U32 -> @+n:U32 -> @+o:U32 -> @+op:Bool -> Em
def emph.go source · line 1758 · raw
@xs:List<&2, Inl> -> @em:Em -> List<&2, Inl>
def emph source · line 1772 · raw
@xs:List<&2, Inl> -> List<&2, Inl>
Emphasis and strong emphasis, by the delimiter run rules.
def flush source · line 1780 · raw
@+buf:String -> @+out:List<&2, Inl> -> List<&2, Inl>
def tick.go source · line 1783 · raw
@s:String -> @hit:Bool -> @+run:Nat -> @+n:Nat -> @acc:String -> Maybe<&2, Got>
def cnl source · line 1799 · raw
@s:String -> String
def cnorm source · line 1807 · 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 1811 · raw
@m:Maybe<&2, Got> -> @+ticks:Nat -> @+after:String -> @+buf:String -> @out:List<&2, Inl> -> Is
def code source · line 1819 · raw
@+s:String -> @+buf:String -> @out:List<&2, Inl> -> Is
def scheme_ch source · line 1824 · raw
@+c:U32 -> Bool
def uri_ch source · line 1827 · raw
@+c:U32 -> Bool
def auto.uri source · line 1830 · raw
@+t:String -> Maybe<&2, Got>
def email_ch source · line 1838 · raw
@+c:U32 -> Bool
def dom_ch source · line 1841 · raw
@+c:U32 -> Bool
def dom.parts source · line 1844 · raw
@xs:List<&2, String> -> Bool
def dom_ok source · line 1852 · raw
@+d:String -> Bool
def auto.email source · line 1856 · raw
@+t:String -> Maybe<&2, Got>
def url.has.of source · line 1863 · raw
@m:Maybe<&2, String> -> Bool
def url.has source · line 1870 · raw
@+p:String -> @+s:String -> Bool
def url.bad source · line 1874 · raw
@+s:String -> Bool
cmark's unsafe schemes. A data: image in PNG, GIF, JPEG, or WebP is safe.
def url source · line 1879 · raw
@safe:Bool -> @+s:String -> String
An href or src value. In safe mode an unsafe URL becomes empty.
def o.safe source · line 1890 · raw
@o:Opts -> Bool
def o.gfm source · line 1895 · raw
@o:Opts -> Bool
def tagf.end source · line 1900 · raw
@m:Maybe<&2, String> -> Bool
def tagf.name source · line 1908 · raw
@+n:String -> @+a:String -> Bool
def tagf.bad source · line 1912 · raw
@+s:String -> Bool
s follows a <. GFM's tag filter blocks these nine tags, open or closed.
def tagf.lt source · line 1916 · raw
@lt:Bool -> @+s:String -> Bool
def tagfilter source · line 1923 · raw
@s:String -> String
def html_out source · line 1932 · raw
@o:Opts -> @+raw:String -> String
Raw HTML as the options render it.
def lt.html source · line 1945 · raw
@m:Maybe<&2, Nat> -> @+s:String -> @+buf:String -> @out:List<&2, Inl> -> @+o:Opts -> Is
def lt.email source · line 1953 · raw
@m:Maybe<&2, Got> -> @+ms:Ms -> @+s:String -> @+buf:String -> @out:List<&2, Inl> -> @+o:Opts -> Is
def lt.uri source · line 1960 · raw
@m:Maybe<&2, Got> -> @+ms:Ms -> @+s:String -> @+buf:String -> @out:List<&2, Inl> -> @+o:Opts -> Is
def amp.got source · line 1967 · raw
@m:Maybe<&2, Got> -> @+t:String -> @buf:String -> @out:List<&2, Inl> -> Is
def nl source · line 1975 · 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 1980 · raw
@+t:String -> @+buf:String -> @+out:List<&2, Inl> -> Is
def delim source · line 1986 · raw
@+c:U32 -> @+s:String -> @+prev:U32 -> @+buf:String -> @+out:List<&2, Inl> -> Is
def al.bound source · line 2001 · raw
@+c:U32 -> Bool
A code point after which an extended autolink may start.
def al.space source · line 2004 · raw
@+c:U32 -> Bool
def al.host source · line 2007 · raw
@+c:U32 -> Bool
def al.cnt source · line 2010 · raw
@+k:U32 -> @s:String -> @+n:Nat -> Nat
def al.last2 source · line 2017 · raw
@xs:List<&2, String> -> @+a:String -> @+b:String -> Pair(String, String)
def al.dom.of source · line 2024 · raw
@+run:String -> @+allow_short:Bool -> @p:Pair(String, String) -> Nat
def al.dom.run source · line 2030 · raw
@p:Pair(String, String) -> String
def al.dom source · line 2035 · 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 2045 · raw
@+c:U32 -> Ak
def al.semi source · line 2050 · raw
@+t:String -> String
def al.trim source · line 2055 · 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 2073 · raw
@+link:String -> String
def al.link source · line 2081 · raw
@+pre:String -> @+text:String -> Maybe<&2, Al>
def al.tail source · line 2085 · 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 2089 · raw
@+s:String -> Maybe<&2, Al>
def al.scheme.of source · line 2092 · raw
@m:Maybe<&2, String> -> @+k:Nat -> @+s:String -> Maybe<&2, Al>
def al.scheme source · line 2100 · raw
@+p:String -> @+s:String -> Maybe<&2, Al>
def al.mail_ch source · line 2103 · raw
@+c:U32 -> Bool
def al.dpart.ok source · line 2106 · raw
@+c:U32 -> @+nx:U32 -> Bool
def al.dpart.go source · line 2109 · raw
@s:String -> @ok:Bool -> @+acc:String -> String
def al.dpart source · line 2121 · raw
@+s:String -> String
The domain of an email after its @, as cmark-gfm's email_match scans it.
def al.mail source · line 2124 · raw
@+s:String -> Maybe<&2, Al>
def al.or source · line 2131 · raw
@a:Maybe<&2, Al> -> @b:Maybe<&2, Al> -> Maybe<&2, Al>
def al source · line 2139 · 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 2142 · raw
@m:Maybe<&2, Al> -> @+y:U32 -> @+t:String -> @+buf:String -> @out:List<&2, Inl> -> @+safe:Bool -> Is
def other source · line 2149 · raw
@try:Bool -> @+y:U32 -> @+t:String -> @+buf:String -> @out:List<&2, Inl> -> @+o:Opts -> Is
def brk source · line 2162 · raw
@out:List<&2, Inl> -> @acc:List<&2, Inl> -> Maybe<&2, Bk>
def deact source · line 2172 · raw
@xs:List<&2, Inl> -> List<&2, Inl>
Deactivates the link brackets below a new link. It stops at an IMark or an inactive bracket, because all brackets below one are already inactive.
def find_ref source · line 2188 · raw
@refs:List<&2, Ref> -> @+label:String -> Maybe<&2, Ref>
def lookup.got source · line 2195 · raw
@m:Maybe<&2, Ref> -> @+rest:String -> Maybe<&2, Lt>
def lookup source · line 2202 · raw
@+refs:List<&2, Ref> -> @+raw:String -> @+rest:String -> Maybe<&2, Lt>
def lookup.raw source · line 2205 · raw
@+refs:List<&2, Ref> -> @m:Maybe<&2, String> -> @+rest:String -> Maybe<&2, Lt>
def ref.full source · line 2212 · raw
@m:Maybe<&2, Got> -> @+t:String -> @+raw:Maybe<&2, String> -> @+refs:List<&2, Ref> -> Maybe<&2, Lt>
def ref.tail source · line 2219 · raw
@+t:String -> @+raw:Maybe<&2, String> -> @+refs:List<&2, Ref> -> Maybe<&2, Lt>
def inl.close.of source · line 2222 · raw
@+d:String -> @v:String -> @m:Maybe<&2, String> -> Maybe<&2, Lt>
def inl.close source · line 2229 · raw
@+d:String -> @tg:Got -> Maybe<&2, Lt>
def inl.title source · line 2234 · raw
@+d:String -> @+c:String -> Maybe<&2, Lt>
def inl.dest source · line 2240 · raw
@+d:String -> @+r:String -> Maybe<&2, Lt>
def inl.got source · line 2244 · raw
@m:Maybe<&2, Got> -> Maybe<&2, Lt>
def inl.open source · line 2251 · raw
@+b:String -> Maybe<&2, Lt>
def inl.tail source · line 2255 · raw
@+t:String -> Maybe<&2, Lt>
An inline link's (destination "title").
def title_attr source · line 2258 · raw
@m:Maybe<&2, String> -> String
def link.make source · line 2265 · raw
@lt:Lt -> @xs:List<&2, Inl> -> @+img:Bool -> @+below:List<&2, Inl> -> @+o:Opts -> Is
def link.fail source · line 2275 · raw
@above:List<&2, Inl> -> @+img:Bool -> @below:List<&2, Inl> -> @+t:String -> Is
def link.try source · line 2278 · raw
@m:Maybe<&2, Lt> -> @above:List<&2, Inl> -> @+img:Bool -> @below:List<&2, Inl> -> @+t:String -> @+o:Opts -> Is
def lab.tick.of source · line 2285 · raw
@m:Maybe<&2, Got> -> @+n:Nat -> Nat
def lab.tick source · line 2292 · raw
@+n:Nat -> @+s:String -> Nat
def lab.lt source · line 2295 · raw
@u:Maybe<&2, Got> -> @e:Maybe<&2, Got> -> @h:Maybe<&2, Nat> -> Nat
def lab.al source · line 2306 · raw
@m:Maybe<&2, Al> -> Nat
def lab.len source · line 2314 · raw
@+c:U32 -> @+prev:U32 -> @+ms:Ms -> @+gfm:Bool -> @+s:String -> Nat
How many code points the piece at s takes, by the inline scanner's rules: an escape, a code span, an autolink, raw HTML, a GFM extended autolink after prev, or one code point.
def lab.go source · line 2322 · raw
@f:Nat -> @+s:String -> @+n:Nat -> @+prev:U32 -> @+ms:Ms -> @+gfm:Bool -> Maybe<&2, Nat>
The length of a bracket's raw label: the text up to the ] that closes it, scanned as the inline scanner scans it. None when another bracket comes first or the label passes 999 code points.
def lab.take source · line 2334 · raw
@m:Maybe<&2, Nat> -> @+after:String -> Maybe<&2, String>
def link.inl source · line 2342 · raw
@m:Maybe<&2, Lt> -> @+above:List<&2, Inl> -> @+img:Bool -> @below:List<&2, Inl> -> @+t:String -> @+after:String -> @+ms:Ms -> @+refs:List<&2, Ref> -> @+o:Opts -> Is
An inline link, else a reference link.
def close.br source · line 2349 · raw
@m:Maybe<&2, Bk> -> @+t:String -> @+out:List<&2, Inl> -> @+refs:List<&2, Ref> -> @+o:Opts -> Is
def ic source · line 2374 · raw
@+c:U32 -> @+nx:U32 -> @+gfm:Bool -> Ic
def opens source · line 2386 · raw
@k:Ic -> @+n:Nat -> Nat
How many brackets are open after a step of kind k.
def misses source · line 2398 · raw
@k:Ic -> @+t:String -> @st:Is -> @+ms:Ms -> Ms
A < step that ends with prev still < was not inline HTML or an autolink.
def istep source · line 2407 · raw
@k:Ic -> @+open:Nat -> @+ms:Ms -> @+y:U32 -> @+t:String -> @+prev:U32 -> @+buf:String -> @+out:List<&2, Inl> -> @+refs:List<&2, Ref> -> @+o:Opts -> Is
def inl.go source · line 2430 · raw
@f:Nat -> @st:Is -> @+open:Nat -> @+ms:Ms -> @+refs:List<&2, Ref> -> @+o:Opts -> List<&2, Inl>
def inline source · line 2446 · raw
@+s:String -> @+refs:List<&2, Ref> -> @+o:Opts -> String
A paragraph or heading's text as HTML.
def cr source · line 2451 · raw
@+out:String -> String
def put source · line 2454 · raw
@s:String -> @out:String -> String
def code_open source · line 2457 · raw
@+info:String -> String
def list_open source · line 2461 · raw
@+ord:Bool -> @+start:U32 -> String
def tbl.join source · line 2467 · 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 2476 · raw
@xs:List<&2, String> -> List<&2, String>
def tbl.cells source · line 2484 · raw
@+row:String -> List<&2, String>
A table row's cells, trimmed, with its outer pipes dropped and \| as |.
def tbl.dcell source · line 2491 · raw
@+c:String -> Bool
def tbl.drow source · line 2497 · raw
@cs:List<&2, String> -> Bool
def tbl.align source · line 2504 · raw
@+c:String -> String
def tbl.aligns source · line 2509 · raw
@cs:List<&2, String> -> List<&2, String>
def tbl.find source · line 2520 · raw
@ls:List<&2, String> -> @+before:List<&2, String> -> Maybe<&2, Tb>
def tbl.row source · line 2535 · 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 2544 · raw
@rows:List<&2, String> -> @+aligns:List<&2, String> -> @+refs:List<&2, Ref> -> @+o:Opts -> String
def tbl.html source · line 2551 · 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 2556 · 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 2560 · raw
@m:Maybe<&2, Tb> -> @+t:String -> @+tight:Bool -> @+refs:List<&2, Ref> -> @+o:Opts -> @+out:String -> String
def r.para source · line 2568 · raw
@gfm:Bool -> @+t:String -> @+tight:Bool -> @+refs:List<&2, Ref> -> @+o:Opts -> @+out:String -> String
def task.kind source · line 2576 · 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 2581 · raw
@task:Bool -> @+k:U32 -> @+t:String -> @+tight:Bool -> @+refs:List<&2, Ref> -> @+o:Opts -> @+out:String -> String
def r.go source · line 2589 · 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 2614 · raw
@+o:Opts -> @r:Pair(List<&2, Kid>, List<&2, Ref>) -> String
def to_html_with source · line 2619 · 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 2623 · raw
@s:String -> String
CommonMark to HTML. Raw HTML and every URL pass through, as the spec requires.
def to_html_safe source · line 2627 · 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
template run source · line 578 · raw
@-p:(@_:U32 -> Bool) -> @+s:String -> Nat
The length of the longest prefix of s whose code points satisfy p.