Documentation
¶
Overview ¶
Package md parses Markdown, following the block and inline structure of CommonMark 0.31 (with the GFM tables, strikethrough, task lists and extended autolinks), and renders it to HTML as a CommonMark renderer does, keeping a map from offsets in the HTML back to offsets in the Markdown. The extractor reads that HTML with the same tree builder and block walker as an HTML page, so the display reasons raw HTML in Markdown declares are read as in a page, and every block's location is in the Markdown source.
The parser follows the reference implementation's line-by-line algorithm (commonmark.js): open containers are continued or closed, new block starts are tried, and lazy continuation lines join a paragraph.
Index ¶
Constants ¶
const MaxNest = 100
MaxNest bounds the nesting of block quotes and lists. A marker past it is read as text.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Doc ¶
type Doc struct {
// GFM turns on the inline extensions of GitHub Flavored Markdown
// when the document is rendered: strikethrough, task-list items and
// extended autolinks. Parse sets it; RenderSpec ignores it. Tables
// are always read.
GFM bool
// contains filtered or unexported fields
}
Doc is a parsed Markdown document.
func (*Doc) Render ¶
Render writes the document as HTML, stopping before limit bytes. Link and image addresses are written as the source has them.
func (*Doc) RenderSpec ¶
RenderSpec writes the document as the CommonMark reference renderer does, with addresses percent-encoded, for comparison with the spec.
type HTML ¶
type HTML struct {
B []byte
// Cut reports that rendering stopped at the size limit.
Cut bool
// Replaced counts the character references to no character (�, a
// surrogate, a number past U+10FFFF) read as U+FFFD.
Replaced int
// contains filtered or unexported fields
}
HTML is a document rendered to HTML.