Parser flags #
The default behavior is to recognize only Markdown syntax defined by the CommonMark specification.
However, with appropriate flags, the behavior can be tuned to enable some extensions.
With the flag MD_FLAG_COLLAPSEWHITESPACE
, a non-trivial whitespace is
collapsed into a single space.
Equations
Instances For
Do not require space in ATX headers ( ###header
)
Equations
Instances For
With the flag MD_FLAG_PERMISSIVEURLAUTOLINKS
permissive URL autolinks
(not enclosed in <
and >
) are supported.
Equations
Instances For
With the flag MD_FLAG_PERMISSIVEEMAILAUTOLINKS
, permissive e-mail
autolinks (not enclosed in <
and >
) are supported.
Equations
Instances For
Disable indented code blocks. (Only fenced code works.)
Equations
Instances For
Disable raw HTML blocks.
Equations
Instances For
Disable raw HTML (inline).
Equations
Instances For
With the flag MD_FLAG_STRIKETHROUGH
, strike-through spans are enabled
(text enclosed in tilde marks, e.g. ~foo bar~
).
Equations
Instances For
With the flag MD_FLAG_PERMISSIVEWWWAUTOLINKS
permissive WWW autolinks
without any scheme specified (e.g. www.example.com
) are supported. MD4C
then assumes http:
scheme.
Equations
Instances For
With the flag MD_FLAG_LATEXMATHSPANS
LaTeX math spans ($...$
) and
LaTeX display math spans ($$...$$
) are supported. (Note though that the
HTML renderer outputs them verbatim in a custom tag <x-equation>
.)
Equations
Instances For
With the flag MD_FLAG_WIKILINKS
, wiki-style links ([[link label]]
and
[[target article|link label]]
) are supported. (Note that the HTML renderer
outputs them in a custom tag <x-wikilink>
.)
Equations
Instances For
With the flag MD_FLAG_UNDERLINE
, underscore (_
) denotes an underline
instead of an ordinary emphasis or strong emphasis.
Equations
- MD4Lean.MD_FLAG_UNDERLINE = 16384
Instances For
Force all soft breaks to act as hard breaks.
Equations
Instances For
Enable all auto-linking.
Equations
Instances For
Disable raw HTML.
Instances For
Convenient sets of flags corresponding to well-known Markdown dialects.
Note we may only support subset of features of the referred dialect. The constant just enables those extensions which bring us as close as possible given what features we implement.
ABI compatibility note: Meaning of these can change in time as new extensions, bringing the dialect closer to the original, are implemented.
The CommonMark dialect.
Equations
Instances For
The GitHub dialect.
Equations
Instances For
HTML renderer flags #
If set, debug output is sent to stderr.
Equations
Instances For
If set, output the entity verbatim, otherwise translate entity to its UTF-8 equivalent.
Equations
Instances For
Skip UTF-8 byte order mark (BOM) in the input string.
Equations
Instances For
Output XHTML (e.g. <br />
) instead of HTML (e.g. <br>
).
Equations
Instances For
Output \(
and \)
(which are accepted by MathJax) instead of <x-equation>
for
LaTeX math spans.
Equations
Instances For
Output $
(which are accepted by MathJax) instead of <x-equation>
for
LaTeX math spans. Must be used with MD_HTML_FLAG_MATHJAX
, otherwise it is ignored.
Equations
Instances For
AST #
The text that can occur in attributes such as link destinations, image sources, and titles
- normal : String → AttrText
Normal text
- entity : String → AttrText
An HTML entity as a complete string, e.g.
" "
.No validation is performed, anything that's syntactically an entity uses this constructor.
- nullchar : AttrText
A null character
Instances For
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
- MD4Lean.instReprAttrText.repr MD4Lean.AttrText.nullchar prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "MD4Lean.AttrText.nullchar")).group prec✝
Instances For
Equations
- MD4Lean.instReprAttrText = { reprPrec := MD4Lean.instReprAttrText.repr }
Equations
- MD4Lean.instBEqAttrText.beq (MD4Lean.AttrText.normal a) (MD4Lean.AttrText.normal b) = (a == b)
- MD4Lean.instBEqAttrText.beq (MD4Lean.AttrText.entity a) (MD4Lean.AttrText.entity b) = (a == b)
- MD4Lean.instBEqAttrText.beq MD4Lean.AttrText.nullchar MD4Lean.AttrText.nullchar = true
- MD4Lean.instBEqAttrText.beq x✝¹ x✝ = false
Instances For
Equations
Inline elements (sometimes called spans or inlines)
- normal : String → Text
Normal text
- nullchar : Text
A null character
- br : String → Text
A hard line break, meaningful for the semantics of the text (see
MD_FLAG_HARD_SOFT_BREAKS
) - softbr : String → Text
A soft line break (renderers will often choose to ignore this)
- entity : String → Text
An HTML entity as a complete string, e.g.
" "
.No validation is performed, anything that's syntactically an entity uses this constructor.
- em : Array Text → Text
Emphasized text, typically italic
- strong : Array Text → Text
Strong emphasis, typically boldface
- u : Array Text → Text
Underlined text (see
MD_FLAG_UNDERLINE
) - a
(href title : Array AttrText)
(isAuto : Bool)
: Array Text → Text
A link.
href
is the destinationtitle
is the provided link title (in quotes after the URL in Markdown syntax)isAuto
is true when the link was created from<
...>
syntax, false otherwise
- img
(src title : Array AttrText)
(alt : Array Text)
: Text
An image.
src
is the source URLtitle
is the provided image title (in quotes after the URL in Markdown syntax)alt
is the alt text for the image, to be shown if the image isn't available
- code : Array String → Text
Code
- del : Array Text → Text
Deleted text, typically shown as a strikethrough
- latexMath : Array String → Text
An inline LaTeX math element, built with
$
...$
(seeMD_FLAG_LATEXMATHSPANS
) - latexMathDisplay : Array String → Text
An display LaTeX math element, built with
$$
...$$
(seeMD_FLAG_LATEXMATHSPANS
) - wikiLink
(target : Array AttrText)
: Array Text → Text
A wiki-style link (see
MD_FLAG_WIKILINKS
)
Instances For
Instances For
Equations
Equations
- MD4Lean.instReprText = { reprPrec := MD4Lean.instReprText.repr }
Equations
A list item
- li :: (
- isTask : Bool
Is this a task?
What is in the checkbox? Always
'X'
,'x'
, or' '
if notnone
. (seeMD_FLAG_TASKLISTS
)Where is the task mark in the document? (see
MD_FLAG_TASKLISTS
)- contents : Array α
The contents of the list item
- )
Instances For
Equations
- MD4Lean.instInhabitedLi = { default := MD4Lean.instInhabitedLi.default }
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- MD4Lean.instReprLi = { reprPrec := MD4Lean.instReprLi.repr }
Equations
- One or more equations did not get rendered due to their size.
- MD4Lean.instBEqLi.beq x✝¹ x✝ = false
Instances For
Equations
- MD4Lean.instBEqLi = { beq := MD4Lean.instBEqLi.beq }
A block-level element
- p : Array Text → Block
A paragraph
- ul
(tight : Bool)
(mark : Char)
: Array (Li Block) → Block
An unordered list
- ol
(tight : Bool)
(start : Nat)
(mark : Char)
: Array (Li Block) → Block
An ordered list
- hr : Block
A thematic break, indicated with
-------
- header : Nat → Array Text → Block
A header
- code
(info lang : Array AttrText)
(fenceChar : Option Char)
: Array String → Block
A code bock (see
MD_FLAG_NOINDENTEDCODEBLOCKS
).The
info
field contains the rest of the text after the initial fence, whilelang
contains the prefix ofinfo
that specifies the language.fenceChar
is the character used to delimit the block (backtick or tilde).For indented code blocks,
info
andlang
are#[]
andfenceChar
isnone
. - html : Array String → Block
Inline HTML block (see
MD_FLAG_NOHTMLBLOCKS
orMD_FLAG_NOHTML
) - blockquote : Array Block → Block
A block quote (introduced with
>
) - table
(head : Array (Array Text))
(body : Array (Array (Array Text)))
: Block
A table
head
is array in which each element is a cell in the headerbody
is array in which each element is a row in the body. Each row is an array of cells.
Instances For
Instances For
Equations
Equations
- MD4Lean.instReprBlock = { reprPrec := MD4Lean.instReprBlock.repr }
Equations
A document
The block-level elements of the document
Instances For
Equations
Equations
- MD4Lean.instInhabitedDocument.default = { blocks := default }
Instances For
Equations
- MD4Lean.instReprDocument = { reprPrec := MD4Lean.instReprDocument.repr }
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
- MD4Lean.instBEqDocument.beq { blocks := a } { blocks := b } = (a == b)
- MD4Lean.instBEqDocument.beq x✝¹ x✝ = false
Instances For
Functions #
Render Markdown into HTML.
Note only contents of <body>
tag is generated. Caller must generate
HTML header/footer manually before/after calling this function.
input
is the input markdown string.parserFlags
is bitmask ofMD_FLAG_xxxx
.rendererFlags
is bitmask ofMD_HTML_FLAG_xxxx
.
Return Option.some s
if render is successful, otherwise return Option.none
.
Parses Markdown into an AST.
input
is the input markdown string.parserFlags
is bitmask ofMD_FLAG_xxxx
.
Returns some
if the underlying md4c parser succeeds, or none
if it fails.