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.
-
CommonMark alone.
-
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.
-
A list item that starts with
[ ],[x], or[X]is a task, not done or done. -
Text between ~ or ~~ is struck through.
-
A link from an http://, https://, or ftp:// URL, a www. address, or an e-mail address, with a space, a line's start, or an opening bracket before it, and a space, a line's end, a closing bracket, or '.', '!', '?', ',', or ';' after it. A host is letters, digits, '.', '-', and '_', a path those and '/', and then a query of those, '&', '+', '=', '(', and ')', and a fragment can follow; one with a port, a '%', or a '~', say, is a link only between '<' and '>', as CommonMark has it.
-
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.
-
The whole document.
-
A block quote.
-
A bullet list.
-
A numbered list.
-
A list's item.
-
A thematic break, a line across.
-
A heading.
-
A block of code.
-
A block of HTML.
-
A paragraph.
-
A table.
-
A table's head.
-
A table's body.
-
A table's row.
-
A cell of a table's head.
-
A cell of a table's body.
-
Emphasized text.
-
Strongly emphasized text.
-
A link.
-
An image.
-
A code span.
-
Struck-through text.
-
Text.
-
A line break that a renderer can make a space.
-
A line break that stays.
-
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
-
As HTML does.
-
To the left.
-
In the middle.
-
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
-
What kind of node it is.
-
What's in it, in order.
-
A Text's or an Html's text, and a CodeBlock's, a Code's, or an HtmlBlock's, which have no children.
-
A Heading's level, from 1 to 6.
-
An OrderedList's first number.
-
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.
-
Whether a ListItem is a task,
- [ ] to do, and whether it's done,- [x] done. -
Whether a task ListItem is done.
-
A Link's URL or an Image's source, and its title.
-
A Link's or an Image's title.
-
Whether a Link is an autolink: https://example.com, or a bare URL with Autolinks.
-
A CodeBlock's info string, like "rust ignore", and its language, the first word of it.
-
A CodeBlock's language, the first word of its info string.
-
A TableHeaderCell's or TableCell's alignment.
-
A new node of
kind, with nothing in it. -
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.
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.
Report an issue with this page or with FutureBlitz on GitHub.