Documentation
¶
Overview ¶
Package mathext is a goldmark extension that recognises TeX math written between dollar delimiters and renders it as MathML. Inline math uses single dollars ($…$), display math uses double dollars ($$…$$). The actual TeX→MathML conversion is delegated to the texmath package; this package only owns the Markdown-level concerns: where a formula starts and ends, and how it serialises into the HTML stream that htmlbag consumes.
Running as a real goldmark inline parser (rather than a regex pre-pass) buys two things for free: dollars inside `code spans` and fenced code blocks are never treated as math, and the strict opening/closing rules below disambiguate prose dollars ("it costs $5 and $6") from formulas — the same convention Pandoc uses and PLOS expects for Markdown submissions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var KindMathInline = ast.NewNodeKind("MathInline")
KindMathInline is the AST node kind for a parsed math span.
var Math = &Extension{}
Math is the ready-to-use extension instance.
Functions ¶
This section is empty.
Types ¶
type Extension ¶
type Extension struct{}
Extension is the goldmark extender. Add it to goldmark.New via goldmark.WithExtensions(mathext.Math).
type MathInline ¶
type MathInline struct {
ast.BaseInline
Source []byte
Display bool
}
MathInline is the AST node a math span parses into. Source is the raw TeX between the delimiters; Display selects $$…$$ (block) over $…$ (inline).
func (*MathInline) Dump ¶
func (n *MathInline) Dump(source []byte, level int)
Dump implements ast.Node for debugging.