htmlclean

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

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Render = ssg.Step("htmlclean", func(_ *ssg.Context, _ ssg.ContentSourceConfig, in []byte) ([]byte, error) {
	div := &html.Node{
		Type:     html.ElementNode,
		DataAtom: atom.Div,
		Data:     "div",
	}
	children, err := html.ParseFragment(bytes.NewReader(in), div)
	if err != nil {
		return nil, err
	}
	var buf bytes.Buffer
	for _, n := range children {
		if err = html.Render(&buf, n); err != nil {
			return nil, err
		}
	}
	return buf.Bytes(), nil
})

Render is a DynStage that parses input as an HTML fragment, normalizes it, and returns the result. This prevents malformed content from breaking the surrounding page layout.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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