Documentation
¶
Overview ¶
Package gutenberg parses WordPress block markup (<!-- wp:ns/name {json} --> … <!-- /wp:ns/name -->) into a tree and converts it to clean HTML for GoRun (spec §4.7). Rendered content (no block comments, as returned by the public REST API) goes through CleanHTML instead.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Autop ¶
Autop wraps classic-editor content (no block markup, no block-level tags) in paragraphs split on blank lines, with single newlines as <br>, like WordPress's wpautop for the simple case.
func CleanHTML ¶
CleanHTML strips WordPress block classes and inline styles (unless o.KeepClasses) from rendered HTML, drops empty class attributes and collapses runs of blank lines. Text, comments and end tags are kept byte for byte.
func Shortcodes ¶
Shortcodes counts shortcode tags ([tag ...]) in s; closing tags are not counted. Tags must look like WordPress shortcode names (lowercase, starting with a letter), so text such as [PDF] or [1] is ignored.
Types ¶
type Block ¶
Block is one parsed block. Name is "core/paragraph" style ("" for freeform HTML between blocks). Parts interleave the block's own HTML with its inner blocks, in document order.
type Options ¶
type Options struct {
// KeepClasses keeps WordPress classes (wp-block-*, has-*, is-*, …) and
// inline styles. Note that content.Sanitize strips non-editor classes and
// all styles on save anyway; the option matters for raw exports.
KeepClasses bool
}
Options tune conversion.
type Result ¶
type Result struct {
HTML string
// Unknown counts blocks without a core converter (inner HTML kept).
Unknown map[string]int
// Shortcodes counts shortcode tags left in place.
Shortcodes map[string]int
}
Result is a conversion outcome.
func ConvertRaw ¶
ConvertRaw converts raw post content: block markup when present, otherwise it is treated as classic/rendered HTML and cleaned.
func (Result) UnknownNames ¶
UnknownNames returns the unknown block names sorted.