Documentation
¶
Overview ¶
Package math implements Obsidian-style LaTeX delimiter parsing for KaTeX auto-render output.
Index ¶
- Constants
- Variables
- func HasMath(root gast.Node) bool
- func IsMathNode(node gast.Node) bool
- func New() goldmark.Extender
- func NewDocumentTransformer() parser.ASTTransformer
- func NewHTMLRenderer() renderer.NodeRenderer
- func NewParagraphTransformer() parser.ParagraphTransformer
- func NewParser() parser.InlineParser
- func RewriteParagraph(node *gast.Paragraph, source []byte) gast.Node
- type DisplayMath
- type HTMLRenderer
- type InlineMath
Constants ¶
const DocumentMetaHasMath = "obsite:has_math"
DocumentMetaHasMath marks parsed documents that contain inline or display math nodes.
Variables ¶
var Extension = &extender{}
Extension wires the math parser, transformer, and renderer into goldmark.
var KindDisplayMath = gast.NewNodeKind("DisplayMath")
KindDisplayMath identifies display math nodes.
var KindInlineMath = gast.NewNodeKind("InlineMath")
KindInlineMath identifies inline math nodes.
Functions ¶
func IsMathNode ¶
IsMathNode reports whether the given node is an Obsite math node.
func NewDocumentTransformer ¶
func NewDocumentTransformer() parser.ASTTransformer
NewDocumentTransformer annotates parsed documents when any math node is present.
func NewHTMLRenderer ¶
func NewHTMLRenderer() renderer.NodeRenderer
NewHTMLRenderer renders math nodes into containers whose text remains KaTeX auto-renderable.
func NewParagraphTransformer ¶
func NewParagraphTransformer() parser.ParagraphTransformer
NewParagraphTransformer rewrites paragraph-only $$...$$ content into a display math node.
func NewParser ¶
func NewParser() parser.InlineParser
NewParser returns the inline parser that recognizes single-dollar math.
Types ¶
type DisplayMath ¶
DisplayMath stores the raw LaTeX content found between double-dollar delimiters.
func NewDisplayMath ¶
func NewDisplayMath(literal []byte) *DisplayMath
NewDisplayMath creates a new display math node.
func (*DisplayMath) Dump ¶
func (n *DisplayMath) Dump(source []byte, level int)
Dump implements gast.Node.
func (*DisplayMath) Text ¶
func (n *DisplayMath) Text(source []byte) []byte
Text implements gast.Node.
type HTMLRenderer ¶
type HTMLRenderer struct{}
func (*HTMLRenderer) RegisterFuncs ¶
func (r *HTMLRenderer) RegisterFuncs(reg renderer.NodeRendererFuncRegisterer)
type InlineMath ¶
type InlineMath struct {
gast.BaseInline
Literal []byte
}
InlineMath stores the raw LaTeX content found between single-dollar delimiters.
func NewInlineMath ¶
func NewInlineMath(literal []byte) *InlineMath
NewInlineMath creates a new inline math node.
func (*InlineMath) Dump ¶
func (n *InlineMath) Dump(source []byte, level int)
Dump implements gast.Node.
func (*InlineMath) Text ¶
func (n *InlineMath) Text(source []byte) []byte
Text implements gast.Node.