Documentation
¶
Overview ¶
Package storage provides types and utilities for working with Confluence Storage Format (XHTML). It includes an intermediate representation (IR) for content blocks, rendering to Storage XHTML, parsing from Storage XHTML, and validation.
Index ¶
- Variables
- func IsValidXML(xhtml string) bool
- func MustValidate(xhtml string)
- func Render(page *Page) (string, error)
- func RenderBlock(block Block) (string, error)
- func RenderMacro(m *Macro) (string, error)
- func Validate(xhtml string) error
- func ValidateBlock(block Block) error
- func ValidateBlockWithOptions(block Block, opts ValidatorOptions) error
- func ValidateWithOptions(xhtml string, opts ValidatorOptions) error
- type Block
- type BulletList
- type Cell
- type CodeBlock
- type Heading
- type HorizontalRule
- type ListItem
- type Macro
- type NumberedList
- type Page
- type Paragraph
- type Row
- type Table
- type ValidationError
- type ValidatorOptions
Constants ¶
This section is empty.
Variables ¶
var AllowedMacros = map[string]bool{}
AllowedMacros is a configurable allowlist of permitted macro names. If empty, all macros are allowed.
var ForbiddenTags = map[string]bool{ "thead": true, "tfoot": true, "colgroup": true, "col": true, "div": true, "span": true, "script": true, "style": true, "iframe": true, "form": true, "input": true, "button": true, }
ForbiddenTags are HTML tags not allowed in Confluence Storage Format.
Functions ¶
func IsValidXML ¶
IsValidXML checks if the string is well-formed XML.
func MustValidate ¶
func MustValidate(xhtml string)
MustValidate panics if validation fails (useful for tests).
func RenderBlock ¶
RenderBlock converts a single Block to Storage XHTML.
func RenderMacro ¶
RenderMacro converts a Macro to Storage XHTML.
func ValidateBlock ¶
ValidateBlock validates a single block's rendered output.
func ValidateBlockWithOptions ¶
func ValidateBlockWithOptions(block Block, opts ValidatorOptions) error
ValidateBlockWithOptions validates a single block's rendered output with options.
func ValidateWithOptions ¶
func ValidateWithOptions(xhtml string, opts ValidatorOptions) error
ValidateWithOptions checks if the given string is valid Confluence Storage XHTML using the provided options.
Types ¶
type Block ¶
type Block interface {
// BlockType returns the type identifier (e.g., "table", "paragraph").
BlockType() string
}
Block represents any content block in Confluence Storage Format.
type BulletList ¶
type BulletList struct {
Items []ListItem `json:"items"`
}
BulletList represents an unordered list.
type HorizontalRule ¶
type HorizontalRule struct{}
HorizontalRule represents a horizontal rule (<hr/>).
func (HorizontalRule) BlockType ¶
func (HorizontalRule) BlockType() string
BlockType implements Block.
type Macro ¶
type Macro struct {
Name string `json:"name"`
Params map[string]string `json:"params,omitempty"`
Body string `json:"body,omitempty"`
}
Macro represents a Confluence macro (ac:structured-macro).
type NumberedList ¶
type NumberedList struct {
Items []ListItem `json:"items"`
}
NumberedList represents an ordered list.
type Page ¶
type Page struct {
Blocks []Block `json:"blocks"`
}
Page represents a full page's content as a sequence of blocks.
type Paragraph ¶
type Paragraph struct {
Text string `json:"text"`
}
Paragraph represents a simple text paragraph.
type ValidationError ¶
ValidationError represents a Storage XHTML validation failure.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
type ValidatorOptions ¶
type ValidatorOptions struct {
// RequireTableTbody requires tables to have <tbody> elements.
RequireTableTbody bool
// AllowedMacros limits which macros are permitted. Empty means all allowed.
AllowedMacros map[string]bool
// ForbiddenTags specifies tags that are not allowed.
ForbiddenTags map[string]bool
}
ValidatorOptions configures validation behavior.
func DefaultValidatorOptions ¶
func DefaultValidatorOptions() ValidatorOptions
DefaultValidatorOptions returns the default validation options.