Skip to content
FutureBlitz

    Install

    Import std.text.markdown

    std.text.markdown

    std.text.markdown: CommonMark, with tables, task lists, strikethrough, and autolinks as asked, over md4c: Markdown as HTML, and as a tree of its blocks, spans, and text to walk.

    std/text/markdown.fb

    Types

    MarkdownExtensions enum

    @Flags Public Enum MarkdownExtensions

    What a document can have past CommonMark, as md4c reads them, which is mostly as GitHub's Markdown does: tables, task lists (- [x] done), strikethrough, and links from bare URLs, www. addresses, and e-mail addresses.

    std/text/markdown.fb, line 23

    • None = 0 enum member #

      CommonMark alone.

    • Tables enum member #

      A table's delimiter row sets its columns, up to 128, so a row's cells past them are left out, and those it lacks are empty. A '|' in a code span doesn't split cells, and a "|" in a cell is a '|', a code span's too.

    • TaskLists enum member #

      A list item that starts with [ ], [x], or [X] is a task, not done or done.

    • Strikethrough enum member #

      Text between ~ or ~~ is struck through.

    • GitHub = Tables | TaskLists | Strikethrough | Autolinks enum member #

      All four, as md4c's dialect of GitHub's Markdown has them.

    MarkdownKind enum

    Public Enum MarkdownKind

    What a node of a document is: a block, a span inside one, or text.

    std/text/markdown.fb, line 47

    • Document enum member #

      The whole document.

    • Quote enum member #

      A block quote.

    • BulletList enum member #

      A bullet list.

    • OrderedList enum member #

      A numbered list.

    • ListItem enum member #

      A list's item.

    • ThematicBreak enum member #

      A thematic break, a line across.

    • Heading enum member #

      A heading.

    • CodeBlock enum member #

      A block of code.

    • HtmlBlock enum member #

      A block of HTML.

    • Paragraph enum member #

      A paragraph.

    • Table enum member #

      A table.

    • TableHead enum member #

      A table's head.

    • TableBody enum member #

      A table's body.

    • TableRow enum member #

      A table's row.

    • TableHeaderCell enum member #

      A cell of a table's head.

    • TableCell enum member #

      A cell of a table's body.

    • Emphasis enum member #

      Emphasized text.

    • Strong enum member #

      Strongly emphasized text.

    • Image enum member #

      An image.

    • Code enum member #

      A code span.

    • Strikethrough enum member #

      Struck-through text.

    • Text enum member #

      Text.

    • SoftBreak enum member #

      A line break that a renderer can make a space.

    • HardBreak enum member #

      A line break that stays.

    • Html enum member #

      HTML in a block's text.

    MarkdownAlignment enum

    Public Enum MarkdownAlignment

    How a table's column lines up its cells: as HTML does unless it says.

    std/text/markdown.fb, line 103

    • None enum member #

      As HTML does.

    • Left enum member #

      To the left.

    • Center enum member #

      In the middle.

    • Right enum member #

      To the right.

    MarkdownNode class

    Public Class MarkdownNode

    A node of a document: a block, like a paragraph or a list, with the blocks, spans, and text in it; a span, like a link, with what's in it; or text.

    std/text/markdown.fb, line 116

    • Public Field Kind: MarkdownKind field #

      What kind of node it is.

    • Public Field Children: MarkdownNode[] field #

      What's in it, in order.

    • Public Field Text = "" field #

      A Text's or an Html's text, and a CodeBlock's, a Code's, or an HtmlBlock's, which have no children.

    • Public Field Level: Int field #

      A Heading's level, from 1 to 6.

    • Public Field Start: Int field #

      An OrderedList's first number.

    • Public Field Tight: Bool field #

      Whether a list is tight, with no blank lines between its items. Its items have no Paragraphs, in HTML or here: each holds its spans and text itself.

    • Public Field Task: Bool field #

      Whether a ListItem is a task, - [ ] to do, and whether it's done, - [x] done.

    • Public Field Done: Bool field #

      Whether a task ListItem is done.

    • Public Field Url = "" field #

      A Link's URL or an Image's source, and its title.

    • Public Field Title = "" field #

      A Link's or an Image's title.

    • Public Field Info = "" field #

      A CodeBlock's info string, like "rust ignore", and its language, the first word of it.

    • Public Field Language = "" field #

      A CodeBlock's language, the first word of its info string.

    • Public Field Alignment: MarkdownAlignment field #

      A TableHeaderCell's or TableCell's alignment.

    • Public New(kind: MarkdownKind) constructor #

      A new node of kind, with nothing in it.

    • Public Method PlainText(): String method #

      The text in it, without the markup: a heading's words, a link's, or an image's description, with a newline for each break. Each block in it, like a paragraph, a list item, or a table's row, is on lines of its own, and a row's cells are apart by a tab. A code block's text has no newline at its end, and raw HTML has none.

    Functions

    MarkdownToHtml function

    Public Function MarkdownToHtml(text: String, extensions: MarkdownExtensions = Usual): String

    The Markdown as HTML: CommonMark, and the extensions, tables and task lists unless they say others; with None, it's CommonMark alone.

    std/text/markdown.fb, line 231

    ParseMarkdown function

    Public Function ParseMarkdown(text: String, extensions: MarkdownExtensions = Usual): MarkdownNode

    The Markdown as a tree, from its Document down, with the extensions, tables and task lists unless they say others.

    std/text/markdown.fb, line 237

    Report an issue with this page or with FutureBlitz on GitHub.