Documentation
¶
Overview ¶
Package subscript provides a Goldmark extension for rendering subscripts using single-tilde syntax.
This extension allows content between single tildes (~text~) to be rendered as HTML subscripts (<sub>text</sub>), while preserving compatibility with Goldmark's strikethrough extension which uses double tildes (~~text~~).
Usage:
md := goldmark.New( goldmark.WithExtensions( subscript.NewSubscript(), ), )
The extension follows these parsing rules:
- Subscripts must not start at the beginning of a line or after whitespace
- Content between tildes cannot contain spaces or additional tildes
- Empty subscripts (~~ with no content) are not parsed as subscripts
Index ¶
Constants ¶
This section is empty.
Variables ¶
var KindSubscript = ast.NewNodeKind("Subscript")
KindSubscript is a NodeKind of the Subscript node.
var Subscript = NewSubscript()
Subscript is a pre-configured subscript extension instance.
var SubscriptAttributeFilter = html.GlobalAttributeFilter
SubscriptAttributeFilter defines attribute names which subscript elements can have. Uses the global HTML attribute filter for consistency with other HTML elements.
Functions ¶
func NewSubscript ¶
func NewSubscript(opts ...SubscriptOption) *subscript
NewSubscript creates a new subscript extension with the given options.
func NewSubscriptHTMLRenderer ¶
func NewSubscriptHTMLRenderer(opts ...html.Option) renderer.NodeRenderer
NewSubscriptHTMLRenderer returns a new SubscriptHTMLRenderer with the given options.
func NewSubscriptParser ¶
func NewSubscriptParser() parser.InlineParser
NewSubscriptParser returns a new InlineParser that parses subscript expressions.
Types ¶
type Node ¶
type Node struct {
ast.BaseInline
}
Node represents a subscript node in the AST.
func NewSubscriptNode ¶
func NewSubscriptNode() *Node
NewSubscriptNode returns a new Subscript node.
type SubscriptHTMLRenderer ¶
SubscriptHTMLRenderer renders Subscript nodes to HTML <sub> elements.
func (*SubscriptHTMLRenderer) RegisterFuncs ¶
func (r *SubscriptHTMLRenderer) RegisterFuncs(reg renderer.NodeRendererFuncRegisterer)
RegisterFuncs implements renderer.NodeRenderer.RegisterFuncs.
type SubscriptOption ¶
type SubscriptOption func(*subscript)
SubscriptOption configures the subscript extension.