std/markdown
Markdown as a document format, written in TorbScript: CommonMark with the tables of GitHub Flavored Markdown and
front matter. Markdown reads a text into a MarkdownDocument, a tree of blocks and inlines that is a value, and
HTML is a separate step over that tree.
const document = Markdown().parse(text)
for block in document.blocks {
if const .Heading(level, inlines) = block.content {
print "{level}: {plainText(inlines)}"
}
}
print document.html()
Every block knows the lines it spans, and every link the line it starts on, so a tool that checks a document can name the line of what it found.
Modules
std/markdown/htmlHTML output, as its own step over the tree: the HTML the CommonMark specification's examples expect, which is commonmark.js's and cmark's, and GitHub's for tables.std/markdown/markdown[Markdown], the format: a value with the options of the reader.std/markdown/treeThe document tree of Markdown: blocks, which hold blocks or inlines, and inlines, which hold text.std/markdown/writerThe writer: a document tree back to Markdown, so that reading what it writes gives the same tree.
Everything
- type
BlockContentWhat a block is. - type
ColumnAlignmentHow a column of a table is aligned, as its delimiter row says. - type
FrontMatterThe front matter of a document: the text between a first line---and the next line---or..., which is YAML. - fn
htmlOfA document as HTML. - type
ListItemOne item of a list: the blocks it holds, and the line of its marker. - type
MarkdownCommonMark, with the tables of GitHub Flavored Markdown and front matter. - type
MarkdownBlockOne block, and the lines it spans, counted from 1. - extend
MarkdownDocument - type
MarkdownDocumentA parsed Markdown document: its blocks, and the front matter it starts with, if any. - extend
MarkdownDocument - type
MarkdownInlineWhat a paragraph, a heading or a cell holds. - type
MarkdownListA bullet list or an ordered list. - fn
markdownOfA document as Markdown, with its front matter. - type
MarkdownTableA table: the alignment of each column, the cells of its header row, and the cells of each row after it. - fn
plainTextThe text of inlines without their markup: what an image'saltis, and what a heading's anchor is made of.