markdown

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package markdown provide AST node types for inline and block KaTeX math expressions.

Package markdown provides KaTeX math expression parsing for goldmark.

Package markdown provides HTML renderer for KaTeX math expressions.

Package markdown provides math rendering for client-side KaTeX

Package markdown provides mermaid diagram rendering extension for goldmark.

Package markdown provides table of contents generation for goldmark.

Index

Constants

This section is empty.

Variables

View Source
var KindKaTeXBlock = ast.NewNodeKind("KaTeXBlock")

KindKaTeXBlock is the NodeKind for block KaTeX math.

View Source
var KindKaTeXInline = ast.NewNodeKind("KaTeXInline")

KindKaTeXInline is the NodeKind for inline KaTeX math.

Functions

func NewMathExtension

func NewMathExtension() goldmark.Extender

NewMathExtension creates a new math extension for client-side KaTeX rendering.

func NewMermaidExtension added in v0.0.20

func NewMermaidExtension() goldmark.Extender

NewMermaidExtension creates a new mermaid diagram rendering extension.

func NewTocExtension

func NewTocExtension() goldmark.Extender

NewTocExtension creates a goldmark extension for table of contents generation.

Types

type KaTeXBlock added in v0.0.24

type KaTeXBlock struct {
	ast.BaseInline
	Equation []byte
}

KaTeXBlock represents a block math expression ($$...$$).

func (*KaTeXBlock) Dump added in v0.0.24

func (n *KaTeXBlock) Dump(source []byte, level int)

Dump outputs the node structure for debugging.

func (*KaTeXBlock) IsBlank added in v0.0.24

func (n *KaTeXBlock) IsBlank(source []byte) bool

IsBlank checks if the node contains only whitespace.

func (*KaTeXBlock) Kind added in v0.0.24

func (n *KaTeXBlock) Kind() ast.NodeKind

Kind returns the node kind for block math.

type KaTeXExtender added in v0.0.24

type KaTeXExtender struct{}

KaTeXExtender implements goldmark.Extender for KaTeX math rendering.

func (*KaTeXExtender) Extend added in v0.0.24

func (e *KaTeXExtender) Extend(m goldmark.Markdown)

Extend adds KaTeX parser and renderer to the goldmark instance.

type KaTeXHTMLRenderer added in v0.0.24

type KaTeXHTMLRenderer struct {
	html.Config
}

KaTeXHTMLRenderer renders KaTeX math nodes as HTML with LaTeX delimiters.

func (*KaTeXHTMLRenderer) RegisterFuncs added in v0.0.24

RegisterFuncs registers rendering functions for KaTeX node types.

type KaTeXInline added in v0.0.24

type KaTeXInline struct {
	ast.BaseInline
	Equation []byte
}

KaTeXInline represents an inline math expression ($...$).

func (*KaTeXInline) Dump added in v0.0.24

func (n *KaTeXInline) Dump(source []byte, level int)

Dump outputs the node structure for debugging.

func (*KaTeXInline) Inline added in v0.0.24

func (n *KaTeXInline) Inline()

Inline marks this as an inline node.

func (*KaTeXInline) IsBlank added in v0.0.24

func (n *KaTeXInline) IsBlank(source []byte) bool

IsBlank checks if the node contains only whitespace.

func (*KaTeXInline) Kind added in v0.0.24

func (n *KaTeXInline) Kind() ast.NodeKind

Kind returns the node kind for inline math.

type KaTeXParser added in v0.0.24

type KaTeXParser struct{}

KaTeXParser parses KaTeX math expressions from markdown.

func (*KaTeXParser) Parse added in v0.0.24

func (s *KaTeXParser) Parse(parent ast.Node, block text.Reader, pc parser.Context) ast.Node

Parse processes a potential KaTeX math expression starting at the current position. Returns an inline or block math node if a valid expression is found, nil otherwise.

func (*KaTeXParser) Trigger added in v0.0.24

func (s *KaTeXParser) Trigger() []byte

Trigger returns the byte that triggers this parser ('$').

type ShortcodeProcessor added in v0.0.33

type ShortcodeProcessor struct {
	// contains filtered or unexported fields
}

ShortcodeProcessor processes shortcodes in markdown before goldmark parsing.

func NewShortcodeProcessor added in v0.0.33

func NewShortcodeProcessor(templates *template.Template) *ShortcodeProcessor

NewShortcodeProcessor creates a new shortcode processor.

func (*ShortcodeProcessor) Process added in v0.0.33

func (sp *ShortcodeProcessor) Process(markdown []byte) ([]byte, error)

Process replaces shortcodes in markdown with rendered HTML.

Jump to

Keyboard shortcuts

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