const TypeCaution, TypeInfo, TypeNote, TypeSuccess, TypeTip, TypeWarning
Types of alerts.
v0 - Unaudited: This is an initial version that has not yet been formally audited. A fully audited version will be pu...
v0 - Unaudited This is an initial version of this package that has not yet been formally audited. A fully audited version will be published as a subsequent release. Use in production at your own risk.
mdalert - Markdown alertsRender gnoweb-flavored Markdown alert blocks (note, tip, info, success, warning, caution) with optional title and folded mode.
1import "gno.land/p/nt/mdalert/v0"
2
3// One-liner helpers per type
4md := mdalert.Warning("Heads up", "Disk almost full")
5
6// Formatted variants accept ufmt-style args
7md = mdalert.Infof("Stats", "%d users online", n)
8
9// Full control via the Alert struct (e.g. folded by default)
10a := mdalert.New(mdalert.TypeTip, "Click to expand", "Hidden details here", true)
11md = a.String()
Rendered output (for the warning above):
> [!WARNING] Heads up
> Disk almost full
1// Type identifies an alert variant.
2type Type string
3
4const (
5 TypeCaution Type = "CAUTION"
6 TypeInfo = "INFO"
7 TypeNote = "NOTE"
8 TypeSuccess = "SUCCESS"
9 TypeTip = "TIP"
10 TypeWarning = "WARNING"
11)
12
13// Alert is a Markdown alert block.
14type Alert struct {
15 Type Type // Alert variant
16 Title string // Optional title (header line)
17 Message string // Body; may contain newlines
18 Folded bool // If true, render collapsed (only title visible)
19}
20
21// String renders the alert as Markdown. Returns "" if Type is empty or Message is blank (whitespace only).
22func (a Alert) String() string
23
24// New builds an Alert.
25func New(t Type, title, msg string, folded bool) Alert
26
27// Per-type helpers (unfolded). The *f variants format msg with ufmt.Sprintf.
28func Caution(title, msg string) string
29func Cautionf(title, format string, a ...any) string
30func Info(title, msg string) string
31func Infof(title, format string, a ...any) string
32func Note(title, msg string) string
33func Notef(title, format string, a ...any) string
34func Success(title, msg string) string
35func Successf(title, format string, a ...any) string
36func Tip(title, msg string) string
37func Tipf(title, format string, a ...any) string
38func Warning(title, msg string) string
39func Warningf(title, format string, a ...any) string
New(...) with folded=true.title and msg are emitted into Markdown as-is. When either carries untrusted input (a Render(path) segment, user text), wrap it with sanitize.InlineText from gno.land/p/nt/markdown/sanitize/v0 first, or it can inject structure into the rendered page. The *f variants format via ufmt.Sprintf, which supports only ufmt's verb subset (no %b, %o, %w, %+v).v0 - Unaudited: This is an initial version that has not yet been formally audited. A fully audited version will be published as a subsequent release. Use in production at your own risk.
Package mdalert provides support for creating Markdown alerts.
Package mdalert provides support for creating Markdown alerts.
It defines supported alert types and helper functions that can be called to generate Markdown for different alert types.
The different alert types are documented in the Markdown docs realm: https://gno.land/r/docs/markdown#alerts
Caution returns an alert Markdown of type caution.
Cautionf returns an alert Markdown of type caution with a formatted message.
Info returns an alert Markdown of type info.
Infof returns an alert Markdown of type info with a formatted message.
Note returns an alert Markdown of type note.
Notef returns an alert Markdown of type note with a formatted message.
Success returns an alert Markdown of type success.
Notef returns an alert Markdown of type success with a formatted message.
Tip returns an alert Markdown of type tip.
Tipf returns an alert Markdown of type tip with a formatted message.
Warning returns an alert Markdown of type warning.
Warningf returns an alert Markdown of type warning with a formatted message.
New creates a new alert.
1type Alert struct {
2 // Type defines the type of alert.
3 Type Type
4
5 // Title contains an optional title for the alert.
6 Title string
7
8 // Message contains alerts's message.
9 Message string
10
11 // Folded indicates that the alert must be folded on render.
12 // Message is not initially visible when folded, only title is visible.
13 Folded bool
14}Alert defines a type for alerts.
Type defines a type for the alert types.