Documentation ¶
Overview ¶
Package rawhtml implements improvements on top of Goldmark's native inline HTML support.
For context, Goldmark's inline HTML parser breaks apart inline HTML elements so that opening and closing tags are treated as separate nodes:
foo <a href="bar">bar</a> baz
Becomes the following nodes:
Text{"foo "} RawHTML{"<a href="bar">"} Text{"bar"} RawHTML{"</a>"} Text{" baz"}
This makes it difficult to parse and manipulate inline HTML elements.
To help work around this, rawhtml augments the parser context with information about open-close tags.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseHTMLFragmentBodies ¶
ParseHTMLFragmentBodies parses fragments of HTML from the given reader. It returns the top-level nodes of the HTML fragments -- unwrapping the <html><head></head> tags, yielding the <body>s. That is, the direct children of each returned node hold the contents of the <body> tag.
Types ¶
type Extender ¶
type Extender struct{}
Extender installs the rawhtml extension into a Goldmark Markdown.
type Pair ¶
Pair is a pair of opening and closing raw HTML nodes.
func PairFromHTML ¶
PairFromHTML formats the given HTML node as a Pair. The node must be an HTML tag with separate open and close tags, and must not have any children. Text needed to render the node is appended to src. Returns an error if the HTML node does not have separate opening and closing tags.
type Transformer ¶
type Transformer struct{}
Transformer searches for raw HTML nodes in the Goldmark document and adds information about pairs to the parser context.
It uses a fairly simple algorithm: For every open tag, scan until the matching close tag.