extensions

package
v1.205.0 Latest Latest
Warning

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

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

Documentation

Overview

Package extensions provides custom goldmark extensions for enhanced markdown syntax.

Package extensions provides custom goldmark extensions for enhanced markdown syntax.

Package extensions provides custom goldmark extensions for enhanced markdown syntax.

Package extensions provides custom goldmark extensions for enhanced markdown syntax.

Package extensions provides custom goldmark extensions for enhanced markdown syntax.

Index

Constants

This section is empty.

Variables

View Source
var AdmonitionKind = ast.NewNodeKind("Admonition")

AdmonitionKind is the kind of Admonition AST node.

View Source
var BadgeKind = ast.NewNodeKind("Badge")

BadgeKind is the kind of Badge AST node.

View Source
var HighlightKind = ast.NewNodeKind("Highlight")

HighlightKind is the kind of Highlight AST node.

View Source
var MutedKind = ast.NewNodeKind("Muted")

MutedKind is the kind of Muted AST node.

View Source
var StrictEmailRegexp = regexp.MustCompile(`[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}`)

StrictEmailRegexp matches valid email addresses but excludes package references. This uses a stricter pattern than goldmark's default that requires:

  • Local part: letters, digits, and common email special chars (._%+-)
  • Domain: letters, digits, hyphens, and dots
  • TLD: at least 2 letters (not numbers)

The TLD requirement is what prevents package references like foo/bar@1.0.0 from matching: ".0" is numeric and doesn't match [a-zA-Z]{2,}.

Matches: user@example.com, support@company.org, user+tag@mail.co. Rejects: foo/bar@1.0.0, replicatedhq/replicated@0.124.1, user@localhost.

Functions

func NewAdmonitionExtension

func NewAdmonitionExtension() goldmark.Extender

NewAdmonitionExtension creates a new admonition extension.

func NewBadgeExtension

func NewBadgeExtension() goldmark.Extender

NewBadgeExtension creates a new badge extension.

func NewHighlightExtension

func NewHighlightExtension() goldmark.Extender

NewHighlightExtension creates a new highlight extension.

func NewMutedExtension

func NewMutedExtension() goldmark.Extender

NewMutedExtension creates a new muted extension.

func NewStrictLinkifyExtension

func NewStrictLinkifyExtension() goldmark.Extender

NewStrictLinkifyExtension creates an extension that prevents package references like foo/bar@1.0.0 from being rendered as mailto: links.

Since glamour uses GFM which includes Linkify with a permissive email regex, this extension adds an AST transformer that runs after parsing and converts auto-linked package references back to plain text.

It identifies package references by:

  • Presence of "/" in the URL (emails cannot contain slashes)
  • URL not matching a strict email pattern (TLD must be letters)

Types

type Admonition

type Admonition struct {
	ast.BaseBlock
	AdmonitionType    AdmonitionType
	AdmonitionContent string
}

Admonition represents a GitHub-style alert block using > [!TYPE] syntax.

func NewAdmonition

func NewAdmonition(admonitionType AdmonitionType, content string) *Admonition

NewAdmonition creates a new Admonition node.

func (*Admonition) Dump

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

Dump dumps the node for debugging.

func (*Admonition) Kind

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

Kind returns the kind of this node.

type AdmonitionType

type AdmonitionType string

AdmonitionType represents the type of admonition.

const (
	AdmonitionNote      AdmonitionType = "NOTE"
	AdmonitionWarning   AdmonitionType = "WARNING"
	AdmonitionTip       AdmonitionType = "TIP"
	AdmonitionImportant AdmonitionType = "IMPORTANT"
	AdmonitionCaution   AdmonitionType = "CAUTION"
)

type Badge

type Badge struct {
	ast.BaseInline
	BadgeVariant string // e.g., "warning", "success", "error", "info", or empty for default
	BadgeText    string // The badge text content
}

Badge represents a styled badge using [!BADGE text] or [!BADGE:variant text] syntax.

func NewBadge

func NewBadge(variant, badgeText string) *Badge

NewBadge creates a new Badge node.

func (*Badge) Dump

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

Dump dumps the node for debugging.

func (*Badge) Kind

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

Kind returns the kind of this node.

type Highlight

type Highlight struct {
	ast.BaseInline
}

Highlight represents highlighted text using ==text== syntax.

func NewHighlight

func NewHighlight() *Highlight

NewHighlight creates a new Highlight node.

func (*Highlight) Dump

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

Dump dumps the node for debugging.

func (*Highlight) Kind

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

Kind returns the kind of this node.

type Muted

type Muted struct {
	ast.BaseInline
}

Muted represents muted/subtle text using ((text)) syntax.

func NewMuted

func NewMuted() *Muted

NewMuted creates a new Muted node.

func (*Muted) Dump

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

Dump dumps the node for debugging.

func (*Muted) Kind

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

Kind returns the kind of this node.

Jump to

Keyboard shortcuts

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