math

package
v1.20.2 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2023 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

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

KindBlock is the node kind for math blocks

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

KindInline is the kind for math inline

View Source
var Math = &Extension{
	enabled:           true,
	parseDollarBlock:  true,
	parseDollarInline: true,
}

Math represents a math extension with default rendered delimiters

Functions

func NewBlockParser

func NewBlockParser(parseDollarBlocks bool) parser.BlockParser

NewBlockParser creates a new math BlockParser

func NewBlockRenderer

func NewBlockRenderer() renderer.NodeRenderer

NewBlockRenderer creates a new renderer for math Blocks

func NewInlineBracketParser

func NewInlineBracketParser() parser.InlineParser

NewInlineDollarParser returns a new inline parser

func NewInlineDollarParser

func NewInlineDollarParser() parser.InlineParser

NewInlineDollarParser returns a new inline parser

func NewInlineRenderer

func NewInlineRenderer() renderer.NodeRenderer

NewInlineRenderer returns a new renderer for inline math

Types

type Block

type Block struct {
	ast.BaseBlock
	Dollars bool
	Indent  int
	Closed  bool
}

Block represents a display math block e.g. $$...$$ or \[...\]

func NewBlock

func NewBlock(dollars bool, indent int) *Block

NewBlock creates a new math Block

func (*Block) Dump

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

Dump dumps the block to a string

func (*Block) IsRaw

func (n *Block) IsRaw() bool

IsRaw returns true as this block should not be processed further

func (*Block) Kind

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

Kind returns KindBlock for math Blocks

type BlockRenderer

type BlockRenderer struct{}

BlockRenderer represents a renderer for math Blocks

func (*BlockRenderer) RegisterFuncs

func (r *BlockRenderer) RegisterFuncs(reg renderer.NodeRendererFuncRegisterer)

RegisterFuncs registers the renderer for math Blocks

type Extension

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

Extension is a math extension

func NewExtension

func NewExtension(opts ...Option) *Extension

NewExtension creates a new math extension with the provided options

func (*Extension) Extend

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

Extend extends goldmark with our parsers and renderers

type Inline

type Inline struct {
	ast.BaseInline
}

Inline represents inline math e.g. $...$ or \(...\)

func NewInline

func NewInline() *Inline

NewInline creates a new ast math inline node

func (*Inline) Dump

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

Dump renders this inline math as debug

func (*Inline) Inline

func (n *Inline) Inline()

Inline implements Inline.Inline.

func (*Inline) IsBlank

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

IsBlank returns if this inline node is empty

func (*Inline) Kind

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

Kind returns KindInline

type InlineRenderer

type InlineRenderer struct{}

InlineRenderer is an inline renderer

func (*InlineRenderer) RegisterFuncs

func (r *InlineRenderer) RegisterFuncs(reg renderer.NodeRendererFuncRegisterer)

RegisterFuncs registers the renderer for inline math nodes

type Option

type Option interface {
	SetOption(e *Extension)
}

Option is the interface Options should implement

func Enabled

func Enabled(enable ...bool) Option

Enabled enables or disables this extension

func WithBlockDollarParser

func WithBlockDollarParser(enable ...bool) Option

WithBlockDollarParser enables or disables the parsing of $$...$$

func WithInlineDollarParser

func WithInlineDollarParser(enable ...bool) Option

WithInlineDollarParser enables or disables the parsing of $...$

Jump to

Keyboard shortcuts

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