math

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package math implements Obsidian-style LaTeX delimiter parsing for KaTeX auto-render output.

Index

Constants

View Source
const DocumentMetaHasMath = "obsite:has_math"

DocumentMetaHasMath marks parsed documents that contain inline or display math nodes.

Variables

View Source
var Extension = &extender{}

Extension wires the math parser, transformer, and renderer into goldmark.

View Source
var KindDisplayMath = gast.NewNodeKind("DisplayMath")

KindDisplayMath identifies display math nodes.

View Source
var KindInlineMath = gast.NewNodeKind("InlineMath")

KindInlineMath identifies inline math nodes.

Functions

func HasMath

func HasMath(root gast.Node) bool

HasMath reports whether the AST contains at least one math node.

func IsMathNode

func IsMathNode(node gast.Node) bool

IsMathNode reports whether the given node is an Obsite math node.

func New

func New() goldmark.Extender

New returns the package-level goldmark extender.

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.

func RewriteParagraph

func RewriteParagraph(node *gast.Paragraph, source []byte) gast.Node

RewriteParagraph applies the package display-math paragraph rewrite contract.

Types

type DisplayMath

type DisplayMath struct {
	gast.BaseBlock
	Literal []byte
}

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) Kind

func (n *DisplayMath) Kind() gast.NodeKind

Kind 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) Kind

func (n *InlineMath) Kind() gast.NodeKind

Kind implements gast.Node.

func (*InlineMath) Text

func (n *InlineMath) Text(source []byte) []byte

Text implements gast.Node.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL