Documentation
¶
Index ¶
Constants ¶
const Version = "0.3.1"
Version specifies the mobiledoc version.
Variables ¶
var DefaultImageSection = func(string) bool { return true }
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": func(Map) bool { return true }, "b": nil, "code": nil, "em": nil, "i": nil, "s": nil, "strong": nil, "sub": nil, "sup": nil, "u": nil, }
DefaultMarkups defines the default expected markups with the tag as the key and a map of attributes and validator functions.
Functions ¶
This section is 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, interface{}) error Cards map[string]func(*bufio.Writer, interface{}) 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.
func (MarkerType) Valid ¶
func (t MarkerType) Valid() bool
Valid returns whether the marker type is valid.
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.
func (SectionType) Valid ¶
func (t SectionType) Valid() bool
Valid returns whether the section type is valid.
type Validator ¶
type Validator struct { // Markups defines the expected markups with the name as key and a map of // attributes and validations functions. Markups map[string]func(Map) bool // Atoms defines the expected atoms with the name as the key and a validator // function. Atoms map[string]func(string, interface{}) bool // Cards defines the expected cards with the name as the key and a validator // function. Cards map[string]func(interface{}) bool // MarkupSections defines the expected markup sections. MarkupSections []string // ListSections defines the expected list sections. ListSections []string // ImageSection defines whether the image section is allowed. ImageSection func(string) bool }
Validator validates a mobiledoc.
func NewValidator ¶
func NewValidator() *Validator
NewValidator creates a validator that validates the mobiledoc standard.