Help us shape the future of Go! Take the 2026 Go Developer Survey

alert

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package alert provides a Goldmark extension for GitHub-style alerts. It transforms blockquotes with [!NOTE], [!TIP], [!IMPORTANT], [!WARNING], or [!CAUTION] into styled alert blocks matching GitHub's markdown rendering.

Index

Constants

This section is empty.

Variables

View Source
var KindAlert = ast.NewNodeKind("Alert")

KindAlert is the kind for Alert nodes

Functions

func NewHTMLRenderer

func NewHTMLRenderer(opts ...html.Option) renderer.NodeRenderer

NewHTMLRenderer creates a new HTMLRenderer

Types

type Alert

type Alert struct {
	ast.BaseBlock
	AlertType AlertType
}

Alert represents a GitHub-style alert block

func NewAlert

func NewAlert(alertType AlertType) *Alert

NewAlert creates a new Alert node

func (*Alert) Dump

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

Dump dumps the alert node

func (*Alert) Kind

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

Kind returns the kind of this node

type AlertType

type AlertType string

AlertType represents the type of alert (note, tip, important, warning, caution)

const (
	AlertTypeNote      AlertType = "note"
	AlertTypeTip       AlertType = "tip"
	AlertTypeImportant AlertType = "important"
	AlertTypeWarning   AlertType = "warning"
	AlertTypeCaution   AlertType = "caution"
)

type Extender

type Extender struct{}

Extender implements goldmark.Extender to add alert support

func New

func New() *Extender

New creates a new alert Extender

func (*Extender) Extend

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

Extend extends the Goldmark parser and renderer with alert functionality

type HTMLRenderer

type HTMLRenderer struct {
	html.Config
}

HTMLRenderer renders Alert nodes to HTML

func (*HTMLRenderer) RegisterFuncs

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

RegisterFuncs registers rendering functions

type Transformer

type Transformer struct{}

Transformer is a transformer that converts blockquotes with alert syntax to Alert nodes

func NewTransformer

func NewTransformer() *Transformer

NewTransformer creates a new Transformer

func (*Transformer) Transform

func (t *Transformer) Transform(node *ast.Document, reader text.Reader, pc parser.Context)

Transform transforms blockquotes into Alert nodes if they match the GitHub alert syntax

Jump to

Keyboard shortcuts

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