alertcallouts

package module
v0.0.0-...-bd2ef18 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2025 License: MIT Imports: 9 Imported by: 1

README

Goldmark Alert Callouts Extension

[!IMPORTANT]

[DEPRECATED]

The main repository for this project has been moved to github.com/zmtcreative/gm-alert-callouts. All future development will be done using that repository!

The new link on pkg.go.dev is github.com/zmtcreative/gm-alert-callouts.

A Goldmark extension that provides support for GitHub-style alerts and Obsidian-style callouts with customizable icons and folding functionality.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AlertCallouts = NewAlertCallouts(
	UseGFMStrictIcons(),
)

AlertCallouts will initialize the extension with the basic GFM icon set This can be initialized using the `goldmark.WithExtensions(alertcallouts.AlertCallouts)` syntax

Functions

func CreateIconsMap added in v0.6.0

func CreateIconsMap(iconData string) map[string]string

CreateIconsMap creates a map of icon names to their SVG data from the given icon data string. This is a public wrapper around the internal utilities function, allowing users to create custom icon maps from their own icon data files.

func NewAlertCallouts added in v0.5.0

func NewAlertCallouts(options ...Option) *alertCalloutsOptions

NewAlertCallouts creates a new AlertCallouts extension with the given options. This follows the standard Goldmark extension initialization pattern.

Types

type Config added in v0.7.0

type Config struct {
	Icons               map[string]string // Icon map for different alert types
	FoldingEnabled      bool              // Whether folding functionality is enabled
	CustomAlertsEnabled bool              // Whether custom alert types are allowed
	DefaultIcons        int               // Which default icon set to use (constants.ICONS_*)
	AllowNOICON         bool              // Whether to allow NOICON alert types (example of new option)
}

Config holds all configuration options for alert callouts rendering. This struct is passed to renderer constructors to avoid long parameter lists and make it easy to add new options without breaking function signatures.

func (*Config) GetIconKeys added in v0.7.0

func (c *Config) GetIconKeys() []string

GetIconKeys returns a slice of all icon keys from the Config.Icons map. This allows access to the icon names without the SVG data, useful for validation, searching, or listing available alert types without the overhead of passing large SVG strings.

type Option added in v0.5.0

type Option func(*alertCalloutsOptions)

Option is a functional option for configuring alertCalloutsOptions.

func UseGFMIcons added in v0.6.0

func UseGFMIcons() Option

UseGFMIcons sets the icon map to the GFM (GitHub Flavored Markdown) icon set. Deprecated: Use UseGFMStrictIcons() instead.

func UseGFMPlusIcons added in v0.6.0

func UseGFMPlusIcons() Option

UseGFMPlusIcons sets the GFMPlus + Aliases that mimic some Obsidian callouts but

still use the default five (5) GFM Alerts

Deprecated: Use UseHybridIcons() instead

func UseGFMStrictIcons added in v0.7.0

func UseGFMStrictIcons() Option

func UseGFMWithAliasesIcons added in v0.7.0

func UseGFMWithAliasesIcons() Option

UseGFMWithAliasesIcons sets the GFM with extra aliases Deprecated: Use UseHybridIcons() instead

func UseHybridIcons added in v0.7.0

func UseHybridIcons() Option

UseGFMPlusIcons sets the icon map to the GFM Plus icon set (essentially a melding of GFM and Obsidian).

func UseObsidianIcons added in v0.6.0

func UseObsidianIcons() Option

UseObsidianIcons sets the icon map to the Obsidian-style icon set.

func WithAllowNOICON added in v0.7.0

func WithAllowNOICON(enable bool) Option

WithAllowNOICON sets whether to allow NOICON prefix to alert types. This is a rendering option -- the parser will ALWAYS strip the 'noicon-' or 'noicon_' prefix

during the parsing phase and set the 'noicon' attribute on the node. It's the renderer
that will use this 'AllowNOICON' option to decide how to handle icons.

func WithCustomAlerts added in v0.7.0

func WithCustomAlerts(enable bool) Option

WithCustomAlerts sets whether to allow custom alert types and titles.

func WithFolding added in v0.5.0

func WithFolding(enable bool) Option

WithFolding sets the folding functionality for alert callouts.

func WithIcon added in v0.5.0

func WithIcon(kind, icon string) Option

WithIcon adds a single icon to the icons map for alert callouts.

func WithIcons added in v0.5.0

func WithIcons(icons map[string]string) Option

WithIcons sets the icons map for alert callouts.

Directories

Path Synopsis
internal
ast

Jump to

Keyboard shortcuts

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