Documentation
¶
Overview ¶
Package gmhtml5 bundles goldmark configuration to: add HTML attributes (notably class) to rendered elements and render standalone images as <figure> with lazy loading.
It composes four capabilities into a single goldmark.Extender:
Heading attributes via goldmark's built-in parser.WithAttribute, e.g. "## Title {#id .cls}".
Block attributes for lists (ul/ol), tables, blockquotes, paragraphs, code blocks, etc. via an attribute list on the line below the block, e.g.
- Apple - Orange {.fruits}
which renders <ul class="fruits">.
Standalone images NOT wrapped in <p>, so an attribute list on the following line attaches to the image rather than the paragraph.
A <figure>/<figcaption> renderer for standalone images, with optional baked-in class, lazy loading, and decoding=async for modern HTML5.
Untrusted input note: like Hugo, the block-attribute transformer strips HTML event handler attributes (on*) defensively. This is not a substitute for a full sanitizer; if you render untrusted markdown, also run the output through a sanitizer such as github.com/microcosm-cc/bluemonday.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Extension ¶
type Extension struct {
// contains filtered or unexported fields
}
Extension is a goldmark.Extender bundling all four attribute capabilities.
type Option ¶
type Option func(*Extension)
Option configures the Extension.
func WithFigureClass ¶
WithFigureClass sets a class added to every emitted <figure>.
func WithoutBlockAttributes ¶
func WithoutBlockAttributes() Option
WithoutBlockAttributes disables attribute lists on block-level elements (headings still get attributes via goldmark's built-in support).
func WithoutFigures ¶
func WithoutFigures() Option
WithoutFigures disables <figure> wrapping; standalone images render as a bare un-wrapped <img> that still accepts a trailing attribute list.
func WithoutLazyImages ¶
func WithoutLazyImages() Option
WithoutLazyImages disables loading="lazy"/decoding="async" on figure images.