mork/document
Types
Block level elements like HR tags, headings, code blocks and paragraphs.
pub type Block {
BlockQuote(blocks: List(Block))
BulletList(pack: ListPack, items: List(ListItem))
Code(lang: option.Option(String), text: String)
Empty
Heading(
level: Int,
id: String,
raw: String,
inlines: List(Inline),
)
HtmlBlock(raw: String)
Newline
OrderedList(
pack: ListPack,
items: List(ListItem),
start: option.Option(Int),
)
Paragraph(raw: String, inlines: List(Inline))
ThematicBreak
}
Constructors
-
BlockQuote(blocks: List(Block)) -
-
Code(lang: option.Option(String), text: String) -
Empty -
Heading( level: Int, id: String, raw: String, inlines: List(Inline), ) -
HtmlBlock(raw: String) -
Newline -
OrderedList( pack: ListPack, items: List(ListItem), start: option.Option(Int), ) -
Paragraph(raw: String, inlines: List(Inline)) -
ThematicBreak
Link destination - Currently classified as Absolute, Relative or Anchor, but this is not really used for anything at the moment.
pub type Destination {
Absolute(uri: String)
Relative(uri: String)
Anchor(id: String)
}
Constructors
-
Absolute(uri: String) -
Relative(uri: String) -
Anchor(id: String)
The root of a parsed Markdown document Contains the Block structure, the list of link references and footnotes1
Footnotes are not yet implemented
pub type Document {
Document(
options: Options,
blocks: List(Block),
links: dict.Dict(String, LinkData),
footnotes: dict.Dict(String, FootnoteData),
)
}
Constructors
Inline elements contained within a block.
pub type Inline {
Autolink(uri: String)
CodeSpan(String)
EmailAutolink(mail: String)
Emphasis(List(Inline))
Footnote(num: Int, label: String)
FullImage(text: List(Inline), data: LinkData)
FullLink(text: List(Inline), data: LinkData)
HardBreak
Highlight(List(Inline))
InlineFootnote(num: Int, text: List(Inline))
InlineHtml(
tag: String,
attrs: dict.Dict(String, String),
children: List(Inline),
)
RawHtml(String)
RefImage(text: List(Inline), label: String)
RefLink(text: List(Inline), label: String)
SoftBreak
Strikethrough(List(Inline))
Strong(List(Inline))
Text(String)
Delim(style: String, len: Int, can_open: Bool, can_close: Bool)
}
Constructors
-
Autolink(uri: String) -
CodeSpan(String) -
EmailAutolink(mail: String) -
Emphasis(List(Inline)) -
Footnote(num: Int, label: String) -
-
-
HardBreak -
Highlight(List(Inline)) -
InlineFootnote(num: Int, text: List(Inline)) -
-
RawHtml(String) -
RefImage(text: List(Inline), label: String) -
RefLink(text: List(Inline), label: String) -
SoftBreak -
Strikethrough(List(Inline)) -
Strong(List(Inline)) -
Text(String) -
Delim(style: String, len: Int, can_open: Bool, can_close: Bool)Delimiters are consecutive runs of * or _, which are first parsed into Delim elements and then resolved into the correct Emphasis, Strong or literal Text in a second pass.
A link reference consists of a destination and an optional title.
pub type LinkData {
LinkData(dest: Destination, title: option.Option(String))
}
Constructors
-
LinkData(dest: Destination, title: option.Option(String))
A list is loose if any of its constituent list items are separated by blank lines, or if any of its constituent list items directly contain two block-level elements with a blank line between them. Otherwise a list is tight. (The difference in HTML output is that paragraphs in a loose list are wrapped in
tags, while paragraphs in a tight list are not.)
pub type ListPack {
Loose
Tight
}
Constructors
-
Loosehttps://spec.commonmark.org/0.31.2/#loose
-
Tighthttps://spec.commonmark.org/0.31.2/#tight
Options for parsing and HTML conversion.
pub type Options {
Options(
strip_frontmatter: Bool,
footnotes: Bool,
heading_ids: Bool,
)
}
Constructors
-
Options( strip_frontmatter: Bool, footnotes: Bool, heading_ids: Bool, )Arguments
- strip_frontmatter
-
Strip YAML frontmatter from input. (default: False)
- footnotes
-
Enable footnote parsing. (default: True)
- heading_ids
-
Add id attribute to headings
Values
pub fn lookup_footnote(
doc: Document,
label: String,
) -> Result(FootnoteData, Nil)
Look up information about a footnote in the document. Returns Error(Nil) if the footnote label has not been defined. Note that this lookup is by label, not by number.
pub fn lookup_link(
doc: Document,
label: String,
) -> Result(LinkData, Nil)
Look up information about a link in the document. Returns Error(Nil) if the link label has not been defined.
pub fn new_destination(uri: String) -> Destination
Creates a link Destination from a string containing a URI.