markdown.bend checks
raw source on the hub · import bend-kit-markdown@0.3.3.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 Mark source · line 696 · raw
Data
KBul@c:U32 -> Mark
KOrd@d:U32 -> Mark
type Kid source · line 701 · 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 704 · 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 715 · 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 721 · 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 729 · 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 733 · raw
Data
The rest of a line and the column it starts at.
Ln@s:String -> @col:U32 -> Ln
type G source · line 783 · raw
Data
G@has:Bool -> @kind:Mark -> @start:U32 -> @items:List<&2, Kid> -> @out:List<&2, Kid> -> G
type Cx source · line 976 · 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 1005 · raw
Data
Hd@lv:U32 -> @text:String -> Hd
type Fg source · line 1020 · raw
Data
Fg@c:U32 -> @n:U32 -> @info:String -> Fg
type Im source · line 1051 · 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 1154 · raw
Data
W@k:Nat -> @ln:Ln -> W
type Lm source · line 1176 · raw
Data
LmNoLm
LmParaLm
LmLeaf@ln:Ln -> Lm
LmEndLm
type Lk source · line 1203 · raw
Data
LkNoneLk
LkParaLk
LkLeafLk
LkUnLk
type P source · line 1210 · 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 1213 · raw
Data
SCont@p:P -> Sr
SStop@p:P -> Sr
SDone@st:St -> Sr
type Inl source · line 1587 · 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 -> Inl
IMarkInl
type Fd source · line 1630 · raw
Data
A matching opener: the inlines after it (oldest first), the opener, and the stack below it.
Fd@above:List<&2, Inl> -> @c:U32 -> @n:U32 -> @o:U32 -> @op:Bool -> @cl:Bool -> @below:List<&2, Inl> -> Fd
type Rs source · line 1633 · raw
Data
RDoneRs
RNoneRs
RFound@fd:Fd -> Rs
type Is source · line 1713 · raw
Data
Is@s:String -> @prev:U32 -> @buf:String -> @out:List<&2, Inl> -> Is
type Opts source · line 1823 · 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 1975 · raw
Data
AkStopAk
AkParenAk
AkPunctAk
AkSemiAk
type Al source · line 2014 · raw
Data
Al@href:String -> @text:String -> Al
type Bk source · line 2096 · 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 -> @below:List<&2, Inl> -> Bk
type Lt source · line 2122 · raw
Data
Lt@dest:String -> @title:Maybe<&2, String> -> @rest:String -> Lt
type Ic source · line 2237 · raw
Data
IcBsIc
IcTickIc
IcStarIc
IcOpenIc
IcBangIc
IcCloseIc
IcLtIc
IcAmpIc
IcNlIc
IcOtherIc
type Tb source · line 2368 · 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 comment source · line 669 · raw
@+s:String -> Maybe<&2, Nat>
def decl source · line 676 · raw
@+s:String -> Maybe<&2, Nat>
def cut.after source · line 683 · raw
@+p:String -> @+s:String -> @+pat:String -> Maybe<&2, Nat>
def raw_html source · line 691 · raw
@+s:String -> Maybe<&2, Nat>
The length of the raw inline HTML at the start of s.
def same_kind source · line 736 · raw
@a:Mark -> @b:Mark -> Bool
def is_ord source · line 745 · raw
@k:Mark -> Bool
def ends source · line 753 · 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 766 · raw
@ks:List<&2, Kid> -> @+next:Bool -> Bool
def loose source · line 773 · raw
@items:List<&2, Kid> -> Bool
def g_flush source · line 786 · raw
@g:G -> List<&2, Kid>
def g_same source · line 796 · raw
@g:G -> @k:Mark -> Bool
def group.item source · line 801 · raw
@same:Bool -> @g:G -> @+k:Kid -> @+kind:Mark -> @+start:U32 -> G
def group.step source · line 810 · raw
@+g:G -> @k:Kid -> G
def group.go source · line 817 · raw
@ks:List<&2, Kid> -> @+g:G -> List<&2, Kid>
def group source · line 825 · raw
@ks:List<&2, Kid> -> List<&2, Kid>
Runs of items of one kind become lists.
def push_kid source · line 828 · raw
@f:Frame -> @k:Kid -> Frame
def add_kid source · line 837 · raw
@stack:List<&2, Frame> -> @k:Kid -> List<&2, Frame>
def join_rev source · line 844 · raw
@lines:List<&2, String> -> String
def drop_blank_lines source · line 847 · raw
@lines:List<&2, String> -> List<&2, String>
def has_ref source · line 854 · raw
@refs:List<&2, Ref> -> @+label:String -> Bool
def add_ref source · line 862 · raw
@+refs:List<&2, Ref> -> @r:Ref -> List<&2, Ref>
The first definition of a label wins.
def defs.go source · line 867 · raw
@f:Nat -> @m:Maybe<&2, RefGot> -> @+s:String -> @+refs:List<&2, Ref> -> Pair(String, List<&2, Ref>)
def defs source · line 879 · 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 882 · raw
@+llb:Bool -> @r:Pair(String, List<&2, Ref>) -> @+stack:List<&2, Frame> -> @+line:U32 -> St
def fence.body source · line 886 · raw
@+lines:List<&2, String> -> String
def close_leaf source · line 889 · raw
@st:St -> St
def frame_kid source · line 904 · raw
@f:Frame -> Kid
def close_frame source · line 914 · raw
@st:St -> St
Closes the innermost container; its leaf must be closed.
def pop source · line 923 · raw
@n:Nat -> @st:St -> St
def ln_s source · line 932 · raw
@ln:Ln -> String
def ln_col source · line 937 · raw
@ln:Ln -> U32
def tabw source · line 942 · raw
@+col:U32 -> U32
def adv.w source · line 945 · raw
@+c:U32 -> @+col:U32 -> U32
def adv.go source · line 949 · 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 967 · 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 972 · raw
@ln:Ln -> Ln
def cx source · line 979 · raw
@+ln:Ln -> Cx
def cx_ln source · line 983 · raw
@c:Cx -> Ln
def cx_at source · line 988 · raw
@c:Cx -> Ln
def cx_ind source · line 993 · raw
@c:Cx -> U32
def cx_blank source · line 998 · raw
@c:Cx -> Bool
def atx.text source · line 1008 · raw
@+t:String -> String
def atx.of source · line 1013 · raw
@+n:Nat -> @+r:String -> Maybe<&2, Hd>
def atx source · line 1016 · raw
@+s:String -> Maybe<&2, Hd>
def fence source · line 1023 · raw
@+s:String -> Maybe<&2, Fg>
def close_fence source · line 1029 · raw
@+s:String -> @+c:U32 -> @+n:U32 -> Bool
def hr.go source · line 1033 · raw
@s:String -> @+c:U32 -> @+n:Nat -> Bool
def hr source · line 1040 · raw
@+s:String -> Bool
def setext source · line 1045 · raw
@+s:String -> U32
1 for a = underline, 2 for -, 0 for neither.
def item.ord source · line 1054 · raw
@+d:String -> @+r:String -> Maybe<&2, Im>
def item.of source · line 1060 · raw
@r:Pair(String, String) -> Maybe<&2, Im>
def item.scan source · line 1064 · raw
@+s:String -> Maybe<&2, Im>
def blocknames source · line 1069 · raw
List<&2, String>
def member source · line 1072 · raw
@xs:List<&2, String> -> @+n:String -> Bool
def html6 source · line 1079 · raw
@+s:String -> Bool
def html1.one source · line 1085 · raw
@m:Maybe<&2, String> -> Bool
def html1 source · line 1093 · raw
@+s:String -> Bool
def html7.ok source · line 1096 · raw
@m:Maybe<&2, Nat> -> @+s:String -> Bool
def html_start.lt source · line 1103 · raw
@lt:Bool -> @+s:String -> @+cpara:Bool -> U32
def html_start source · line 1117 · 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 1120 · raw
@+k:U32 -> @+s:String -> Bool
def after_gt source · line 1129 · raw
@at:Ln -> Ln
def quote_cont source · line 1134 · raw
@c:Cx -> Maybe<&2, Ln>
def item_cont source · line 1139 · raw
@+hc:Bool -> @+pad:U32 -> @c:Cx -> Maybe<&2, Ln>
def cont source · line 1145 · 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 1157 · raw
@frames:List<&2, Frame> -> @+ln:Ln -> @+leafnone:Bool -> Maybe<&2, Ln>
def walk source · line 1165 · 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 1182 · raw
@leaf:Leaf -> @c:Cx -> Lm
def p_ln source · line 1218 · raw
@p:P -> Ln
def p_tipp source · line 1223 · raw
@p:P -> Bool
def p_cpara source · line 1228 · raw
@p:P -> Bool
def p_line source · line 1237 · raw
@p:P -> U32
def push_frame source · line 1242 · raw
@st:St -> @f:Frame -> St
def set_leaf source · line 1247 · raw
@st:St -> @leaf:Leaf -> St
def add_kid_st source · line 1252 · raw
@st:St -> @k:Kid -> St
def unmatched source · line 1258 · raw
@p:P -> P
Closes the containers, and the leaf, that the line did not continue.
def prep.go source · line 1267 · raw
@p:P -> St
def prep source · line 1273 · raw
@p:P -> St
Ready for a new block: unmatched blocks closed, and the leaf closed.
def try.code source · line 1276 · raw
@+p:P -> @c:Cx -> Sr
def item.open source · line 1281 · raw
@im:Im -> @+p:P -> @+c:Cx -> Sr
def try.item source · line 1293 · raw
@m:Maybe<&2, Im> -> @+p:P -> @+c:Cx -> Sr
def try.hr source · line 1300 · raw
@ok:Bool -> @+p:P -> @+c:Cx -> Sr
def setext.close source · line 1307 · raw
@+lv:U32 -> @r:Pair(String, List<&2, Ref>) -> @+stack:List<&2, Frame> -> @+line:U32 -> @+p:P -> Sr
def setext.apply source · line 1311 · raw
@+lv:U32 -> @+p:P -> Sr
def try.setext source · line 1320 · raw
@ok:Bool -> @+lv:U32 -> @+p:P -> @+c:Cx -> Sr
def html.open source · line 1327 · raw
@+k:U32 -> @+p:P -> @+c:Cx -> Sr
def try.html source · line 1332 · raw
@+k:U32 -> @+p:P -> @+c:Cx -> Sr
def try.fence source · line 1336 · raw
@m:Maybe<&2, Fg> -> @+p:P -> @+c:Cx -> Sr
def try.atx source · line 1343 · raw
@m:Maybe<&2, Hd> -> @+p:P -> @+c:Cx -> Sr
def try.quote source · line 1350 · raw
@ok:Bool -> @+p:P -> @+c:Cx -> Sr
def starts.try source · line 1357 · raw
@+p:P -> Sr
def starts.go source · line 1361 · raw
@f:Nat -> @r:Sr -> Sr
def f_reset source · line 1374 · raw
@f:Frame -> Frame
def reset_all source · line 1383 · raw
@stack:List<&2, Frame> -> List<&2, Frame>
def kid_blank source · line 1390 · raw
@ks:List<&2, Kid> -> List<&2, Kid>
def f_blank source · line 1398 · 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 1407 · raw
@st:St -> St
def head_blank source · line 1412 · raw
@st:St -> St
def leaf_llb source · line 1421 · raw
@st:St -> @+blank:Bool -> St
def st_leaf source · line 1432 · raw
@st:St -> Leaf
def leaf_none source · line 1437 · raw
@leaf:Leaf -> Bool
def leaf_para source · line 1444 · raw
@leaf:Leaf -> Bool
def leaf_add source · line 1451 · raw
@st:St -> @+s:String -> St
def text.put source · line 1467 · raw
@p:P -> @+c:Cx -> St
def text.lazy source · line 1478 · raw
@lazy:Bool -> @+p:P -> @+c:Cx -> St
def text.add source · line 1488 · 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 1496 · raw
@r:Sr -> St
def line.run source · line 1505 · raw
@p:P -> @+ln:Ln -> St
def line.lm source · line 1508 · raw
@m:Lm -> @+st:St -> @+ln:Ln -> @+tipp:Bool -> St
def line.pops source · line 1519 · raw
@un:Bool -> @+pops:Nat -> @+st:St -> @+ln:Ln -> @+tipp:Bool -> St
def line.walked source · line 1526 · raw
@w:W -> @+st:St -> @+depth:Nat -> @+tipp:Bool -> St
def line source · line 1532 · raw
@st:St -> @raw:String -> St
def doc.go source · line 1540 · raw
@lines:List<&2, String> -> @st:St -> St
def finish.doc source · line 1547 · raw
@st:St -> Pair(List<&2, Kid>, List<&2, Ref>)
def finish source · line 1556 · raw
@st:St -> Pair(List<&2, Kid>, List<&2, Ref>)
def clean source · line 1561 · raw
@s:String -> String
def drop_cr source · line 1568 · raw
@+l:String -> String
def lines.go source · line 1571 · raw
@xs:List<&2, String> -> List<&2, String>
def blocks source · line 1581 · 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 1594 · raw
@+c:U32 -> @n:U32 -> String
def r.inl source · line 1597 · raw
@xs:List<&2, Inl> -> String
def p.inl source · line 1612 · raw
@xs:List<&2, Inl> -> String
def odd_fail source · line 1639 · 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 1642 · raw
@stack:List<&2, Inl> -> @+c:U32 -> @+orig:U32 -> @+copen:Bool -> @+acc:List<&2, Inl> -> Maybe<&2, Fd>
def rs.of source · line 1652 · raw
@m:Maybe<&2, Fd> -> Rs
def seek source · line 1659 · raw
@more:Bool -> @stack:List<&2, Inl> -> @+c:U32 -> @+orig:U32 -> @+copen:Bool -> Rs
def wrap source · line 1666 · raw
@+c:U32 -> @+use:U32 -> @+xs:List<&2, Inl> -> Inl
def keep source · line 1671 · raw
@+n:U32 -> @+c:U32 -> @+o:U32 -> @+op:Bool -> @+cl:Bool -> @+below:List<&2, Inl> -> List<&2, Inl>
def resolve source · line 1675 · 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 1691 · raw
@cl:Bool -> @+stack:List<&2, Inl> -> @+c:U32 -> @+n:U32 -> @+o:U32 -> @+op:Bool -> List<&2, Inl>
def emph.go source · line 1698 · raw
@xs:List<&2, Inl> -> @+stack:List<&2, Inl> -> List<&2, Inl>
def emph source · line 1708 · raw
@xs:List<&2, Inl> -> List<&2, Inl>
Emphasis and strong emphasis, by the delimiter run rules.
def flush source · line 1716 · raw
@+buf:String -> @+out:List<&2, Inl> -> List<&2, Inl>
def tick.go source · line 1719 · raw
@s:String -> @hit:Bool -> @+run:Nat -> @+n:Nat -> @acc:String -> Maybe<&2, Got>
def cnl source · line 1735 · raw
@s:String -> String
def cnorm source · line 1743 · 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 1747 · raw
@m:Maybe<&2, Got> -> @+ticks:Nat -> @+after:String -> @+buf:String -> @out:List<&2, Inl> -> Is
def code source · line 1755 · raw
@+s:String -> @+buf:String -> @out:List<&2, Inl> -> Is
def scheme_ch source · line 1760 · raw
@+c:U32 -> Bool
def uri_ch source · line 1763 · raw
@+c:U32 -> Bool
def auto.uri source · line 1766 · raw
@+t:String -> Maybe<&2, Got>
def email_ch source · line 1774 · raw
@+c:U32 -> Bool
def dom_ch source · line 1777 · raw
@+c:U32 -> Bool
def dom.parts source · line 1780 · raw
@xs:List<&2, String> -> Bool
def dom_ok source · line 1788 · raw
@+d:String -> Bool
def auto.email source · line 1792 · raw
@+t:String -> Maybe<&2, Got>
def url.has.of source · line 1799 · raw
@m:Maybe<&2, String> -> Bool
def url.has source · line 1806 · raw
@+p:String -> @+s:String -> Bool
def url.bad source · line 1810 · raw
@+s:String -> Bool
cmark's unsafe schemes. A data: image in PNG, GIF, JPEG, or WebP is safe.
def url source · line 1815 · raw
@safe:Bool -> @+s:String -> String
An href or src value. In safe mode an unsafe URL becomes empty.
def o.safe source · line 1826 · raw
@o:Opts -> Bool
def o.gfm source · line 1831 · raw
@o:Opts -> Bool
def tagf.end source · line 1836 · raw
@m:Maybe<&2, String> -> Bool
def tagf.name source · line 1844 · raw
@+n:String -> @+a:String -> Bool
def tagf.bad source · line 1848 · raw
@+s:String -> Bool
s follows a <. GFM's tag filter blocks these nine tags, open or closed.
def tagf.lt source · line 1852 · raw
@lt:Bool -> @+s:String -> Bool
def tagfilter source · line 1859 · raw
@s:String -> String
def html_out source · line 1868 · raw
@o:Opts -> @+raw:String -> String
Raw HTML as the options render it.
def lt.html source · line 1881 · raw
@m:Maybe<&2, Nat> -> @+s:String -> @+buf:String -> @out:List<&2, Inl> -> @+o:Opts -> Is
def lt.email source · line 1889 · raw
@m:Maybe<&2, Got> -> @+s:String -> @+buf:String -> @out:List<&2, Inl> -> @+o:Opts -> Is
def lt.uri source · line 1896 · raw
@m:Maybe<&2, Got> -> @+s:String -> @+buf:String -> @out:List<&2, Inl> -> @+o:Opts -> Is
def amp.got source · line 1903 · raw
@m:Maybe<&2, Got> -> @+t:String -> @buf:String -> @out:List<&2, Inl> -> Is
def nl source · line 1911 · 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 1916 · raw
@+t:String -> @+buf:String -> @+out:List<&2, Inl> -> Is
def delim source · line 1922 · raw
@+c:U32 -> @+s:String -> @+prev:U32 -> @+buf:String -> @+out:List<&2, Inl> -> Is
def al.bound source · line 1937 · raw
@+c:U32 -> Bool
A code point after which an extended autolink may start.
def al.space source · line 1940 · raw
@+c:U32 -> Bool
def al.host source · line 1943 · raw
@+c:U32 -> Bool
def al.cnt source · line 1946 · raw
@+k:U32 -> @s:String -> @+n:Nat -> Nat
def al.last2 source · line 1953 · raw
@xs:List<&2, String> -> @+a:String -> @+b:String -> Pair(String, String)
def al.dom.of source · line 1960 · raw
@+run:String -> @+allow_short:Bool -> @p:Pair(String, String) -> Nat
def al.dom.run source · line 1966 · raw
@p:Pair(String, String) -> String
def al.dom source · line 1971 · 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 1981 · raw
@+c:U32 -> Ak
def al.semi source · line 1986 · raw
@+t:String -> String
def al.trim source · line 1991 · 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 2009 · raw
@+link:String -> String
def al.link source · line 2017 · raw
@+pre:String -> @+text:String -> Maybe<&2, Al>
def al.tail source · line 2021 · 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 2025 · raw
@+s:String -> Maybe<&2, Al>
def al.scheme.of source · line 2028 · raw
@m:Maybe<&2, String> -> @+s:String -> Maybe<&2, Al>
def al.scheme source · line 2037 · raw
@+p:String -> @+s:String -> Maybe<&2, Al>
def al.mail_ch source · line 2040 · raw
@+c:U32 -> Bool
def al.dpart.ok source · line 2043 · raw
@+c:U32 -> @+nx:U32 -> Bool
def al.dpart.go source · line 2046 · raw
@s:String -> @ok:Bool -> @+acc:String -> String
def al.dpart source · line 2058 · raw
@+s:String -> String
The domain of an email after its @, as cmark-gfm's email_match scans it.
def al.mail source · line 2061 · raw
@+s:String -> Maybe<&2, Al>
def al.or source · line 2068 · raw
@a:Maybe<&2, Al> -> @b:Maybe<&2, Al> -> Maybe<&2, Al>
def al source · line 2076 · 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 2079 · raw
@m:Maybe<&2, Al> -> @+y:U32 -> @+t:String -> @+buf:String -> @out:List<&2, Inl> -> @+safe:Bool -> Is
def other source · line 2086 · raw
@try:Bool -> @+y:U32 -> @+t:String -> @+buf:String -> @out:List<&2, Inl> -> @+o:Opts -> Is
def brk source · line 2099 · raw
@out:List<&2, Inl> -> @acc:List<&2, Inl> -> Maybe<&2, Bk>
def deact source · line 2109 · 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 2125 · raw
@refs:List<&2, Ref> -> @+label:String -> Maybe<&2, Ref>
def lookup.got source · line 2132 · raw
@m:Maybe<&2, Ref> -> @+rest:String -> Maybe<&2, Lt>
def lookup source · line 2139 · raw
@+refs:List<&2, Ref> -> @+raw:String -> @+rest:String -> Maybe<&2, Lt>
def ref.full source · line 2142 · raw
@m:Maybe<&2, Got> -> @+t:String -> @+raw:String -> @+refs:List<&2, Ref> -> Maybe<&2, Lt>
def ref.tail source · line 2149 · raw
@+t:String -> @+raw:String -> @+refs:List<&2, Ref> -> Maybe<&2, Lt>
def inl.close.of source · line 2152 · raw
@+d:String -> @v:String -> @m:Maybe<&2, String> -> Maybe<&2, Lt>
def inl.close source · line 2159 · raw
@+d:String -> @tg:Got -> Maybe<&2, Lt>
def inl.title source · line 2164 · raw
@+d:String -> @+c:String -> Maybe<&2, Lt>
def inl.dest source · line 2170 · raw
@+d:String -> @+r:String -> Maybe<&2, Lt>
def inl.got source · line 2174 · raw
@m:Maybe<&2, Got> -> Maybe<&2, Lt>
def inl.open source · line 2181 · raw
@+b:String -> Maybe<&2, Lt>
def inl.tail source · line 2185 · raw
@+t:String -> Maybe<&2, Lt>
An inline link's (destination "title").
def title_attr source · line 2188 · raw
@m:Maybe<&2, String> -> String
def link.make source · line 2195 · raw
@lt:Lt -> @xs:List<&2, Inl> -> @+img:Bool -> @+below:List<&2, Inl> -> @+o:Opts -> Is
def link.fail source · line 2205 · raw
@above:List<&2, Inl> -> @+img:Bool -> @below:List<&2, Inl> -> @+t:String -> Is
def link.try source · line 2208 · raw
@m:Maybe<&2, Lt> -> @above:List<&2, Inl> -> @+img:Bool -> @below:List<&2, Inl> -> @+t:String -> @+o:Opts -> Is
def link.inl source · line 2216 · raw
@m:Maybe<&2, Lt> -> @above:List<&2, Inl> -> @+img:Bool -> @below:List<&2, Inl> -> @+t:String -> @+after:String -> @+refs:List<&2, Ref> -> @+o:Opts -> Is
An inline link, else a reference link. The raw label costs the length of the rest of the paragraph, so it waits for the inline link to fail.
def close.br source · line 2224 · raw
@m:Maybe<&2, Bk> -> @+t:String -> @+out:List<&2, Inl> -> @+refs:List<&2, Ref> -> @+o:Opts -> Is
def ic source · line 2249 · raw
@+c:U32 -> @+nx:U32 -> @+gfm:Bool -> Ic
def istep source · line 2260 · 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 2283 · raw
@f:Nat -> @st:Is -> @+refs:List<&2, Ref> -> @+o:Opts -> List<&2, Inl>
def inline source · line 2297 · raw
@+s:String -> @+refs:List<&2, Ref> -> @+o:Opts -> String
A paragraph or heading's text as HTML.
def cr source · line 2302 · raw
@+out:String -> String
def put source · line 2305 · raw
@s:String -> @out:String -> String
def code_open source · line 2308 · raw
@+info:String -> String
def list_open source · line 2312 · raw
@+ord:Bool -> @+start:U32 -> String
def tbl.join source · line 2318 · 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 2327 · raw
@xs:List<&2, String> -> List<&2, String>
def tbl.cells source · line 2335 · raw
@+row:String -> List<&2, String>
A table row's cells, trimmed, with its outer pipes dropped and \| as |.
def tbl.dcell source · line 2342 · raw
@+c:String -> Bool
def tbl.drow source · line 2348 · raw
@cs:List<&2, String> -> Bool
def tbl.align source · line 2355 · raw
@+c:String -> String
def tbl.aligns source · line 2360 · raw
@cs:List<&2, String> -> List<&2, String>
def tbl.find source · line 2371 · raw
@ls:List<&2, String> -> @+before:List<&2, String> -> Maybe<&2, Tb>
def tbl.row source · line 2386 · 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 2395 · raw
@rows:List<&2, String> -> @+aligns:List<&2, String> -> @+refs:List<&2, Ref> -> @+o:Opts -> String
def tbl.html source · line 2402 · 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 2407 · 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 2411 · raw
@m:Maybe<&2, Tb> -> @+t:String -> @+tight:Bool -> @+refs:List<&2, Ref> -> @+o:Opts -> @+out:String -> String
def r.para source · line 2419 · raw
@gfm:Bool -> @+t:String -> @+tight:Bool -> @+refs:List<&2, Ref> -> @+o:Opts -> @+out:String -> String
def task.kind source · line 2427 · 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 2432 · raw
@task:Bool -> @+k:U32 -> @+t:String -> @+tight:Bool -> @+refs:List<&2, Ref> -> @+o:Opts -> @+out:String -> String
def r.go source · line 2440 · 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 2465 · raw
@+o:Opts -> @r:Pair(List<&2, Kid>, List<&2, Ref>) -> String
def to_html_with source · line 2470 · 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 2474 · raw
@s:String -> String
CommonMark to HTML. Raw HTML and every URL pass through, as the spec requires.
def to_html_safe source · line 2478 · 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.