Documentation ¶
Index ¶
Constants ¶
const Version = "0.3.1"
Version specifies the mobiledoc version.
Variables ¶
var DefaultImageSection = func(source string) bool { return len(source) > 0 }
DefaultImageSection defines the default image section validator.
var DefaultListSections = []string{"ul", "ol"}
DefaultListSections defines the default list sections.
var DefaultMarkupSections = []string{"aside", "blockquote", "h1", "h2", "h3", "h4", "h5", "h6", "p"}
DefaultMarkupSections defines the default markup sections.
var DefaultMarkups = map[string]func(Map) bool{ "a": LinkValidator, "b": NoAttributesValidator, "code": NoAttributesValidator, "em": NoAttributesValidator, "i": NoAttributesValidator, "s": NoAttributesValidator, "strong": NoAttributesValidator, "sub": NoAttributesValidator, "sup": NoAttributesValidator, "u": NoAttributesValidator, }
DefaultMarkups defines the default expected markups with the tag as the key and a map of attributes and validator functions.
Functions ¶
func LinkValidator ¶
LinkValidator validates the href attribute.
func NoAttributesValidator ¶
NoAttributesValidator returns true if the provided attributes are empty.
Types ¶
type Document ¶
type Document struct { Version string Markups []Markup Atoms []Atom Cards []Card Sections []Section }
Document is a mobiledoc.
type HTMLRenderer ¶
type HTMLRenderer struct { Atoms map[string]func(*bufio.Writer, string, Map) error Cards map[string]func(*bufio.Writer, Map) error }
HTMLRenderer implements a basic HTML renderer.
func NewHTMLRenderer ¶
func NewHTMLRenderer() *HTMLRenderer
NewHTMLRenderer creates a new HTMLRenderer.
type Marker ¶
type Marker struct { Type MarkerType OpenMarkups []*Markup ClosedMarkups int Text string Atom *Atom }
Marker is a single marker.
type MarkerType ¶
type MarkerType int
MarkerType defines a marker type.
const ( TextMarker MarkerType = 0 AtomMarker MarkerType = 1 )
The available marker identifiers.
type Section ¶
type Section struct { Type SectionType Tag string Markers []Marker Source string Items [][]Marker Card *Card }
Section is a single section.
type SectionType ¶
type SectionType int
SectionType defines a section type.
const ( MarkupSection SectionType = 1 ImageSection SectionType = 2 ListSection SectionType = 3 CardSection SectionType = 10 )
The available section identifiers.
type Validator ¶
type Validator struct { // Markups defines the allowed markups with the name as key and a // attributes validator function. Markups map[string]func(attributes Map) bool // Atoms defines the allowed atoms with the name as the key and a validator // function. Atoms map[string]func(name string, payload Map) bool // Cards defines the allowed cards with the name as the key and a validator // function. Cards map[string]func(payload Map) bool // MarkupSections defines the allowed markup sections. MarkupSections []string // ListSections defines the allowed list sections. ListSections []string // ImageSection defines whether the image section is allowed when a source // validator is set. ImageSection func(source string) bool }
Validator validates a mobiledoc.
func NewDefaultValidator ¶
func NewDefaultValidator() *Validator
NewDefaultValidator creates a validator that validates the default mobiledoc standard.
func NewEmptyValidator ¶
func NewEmptyValidator() *Validator
NewEmptyValidator creates an empty validator.