goldmark

package
v0.0.0-...-9a8c79c Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package goldmark provides a goldmark extension for rendering LaTeX math in the terminal using termtex.

It recognizes $...$ for inline math and $$...$$ for display math blocks, parsing them into custom AST nodes that are rendered by calling termtex.

Usage with goldmark directly:

md := goldmark.New(goldmark.WithExtensions(goldmark.NewMathExtension()))
md.Convert(source, os.Stdout)

Usage with glamour (requires building a custom renderer — see example/):

// See the example program for the full glamour integration pattern.

Index

Constants

This section is empty.

Variables

View Source
var KindMathBlock = ast.NewNodeKind("MathBlock")

KindMathBlock is the AST node kind for display math ($$...$$).

View Source
var KindMathInline = ast.NewNodeKind("MathInline")

KindMathInline is the AST node kind for inline math ($...$).

Functions

This section is empty.

Types

type MathBlock

type MathBlock struct {
	ast.BaseBlock
	Expression []byte
	// contains filtered or unexported fields
}

MathBlock represents a display math block.

func (*MathBlock) Dump

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

func (*MathBlock) Kind

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

type MathExtension

type MathExtension struct {
	Style termtex.Style
}

MathExtension is a goldmark extension that adds LaTeX math support. It recognizes $...$ for inline math and $$...$$ for display math, rendering them with termtex.

func NewMathExtension

func NewMathExtension() *MathExtension

NewMathExtension creates a new math extension with the default (zero-value) style.

func NewMathExtensionWithStyle

func NewMathExtensionWithStyle(style termtex.Style) *MathExtension

NewMathExtensionWithStyle creates a new math extension with custom style.

func (*MathExtension) Extend

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

Extend implements goldmark.Extender.

type MathInline

type MathInline struct {
	ast.BaseInline
	Expression []byte
}

MathInline represents an inline math expression.

func (*MathInline) Dump

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

func (*MathInline) Kind

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

Jump to

Keyboard shortcuts

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