std/markdown/writer

std/markdown/src/writer.trb

The writer: a document tree back to Markdown, so that reading what it writes gives the same tree. It writes one form for each construct - * and **, fenced code, - and 1. lists, ATX headings where a heading fits on one line - and escapes every character of a text that could be read as markup.

extend MarkdownDocument

extend MarkdownDocument

Adds markdown to a document, to write it back as Markdown text.

Examples

var inlines: List<MarkdownInline> = []
inlines.append MarkdownInline.Text("Hello")
const block = MarkdownBlock BlockContent.Paragraph(inlines)
var blocks: List<MarkdownBlock> = []
blocks.append block
const document = MarkdownDocument blocks
print document.markdown()

fn markdown

fn markdown(): String

The document as Markdown text, with its front matter, which reads back as this document.