Documentation
¶
Index ¶
- Variables
- func NewDocumentConstructor(i io.Reader) *documentConstructor
- func Open(p string) (*documentConstructor, error)
- type BlockHTMLRender
- type BlockObject
- type BlockObjectRender
- type BlockObjectType
- type Document
- type InlineContent
- type InlineHTMLTag
- type InlineHTMLTagset
- type InlineObject
- type InlineObjectType
- type InlineOpLen
- type InlineSort
- type InlineTag
- type InlineTagType
- type InlineTags
- type ListAttribs
- type ListOrder
- type SpecialAction
- type Specials
Constants ¶
This section is empty.
Variables ¶
View Source
var BlockHTMLTags map[BlockObjectType]BlockHTMLRender = map[BlockObjectType]BlockHTMLRender{ Paragraph: BlockHTMLRender{ Opener: "<p>", Closer: "</p>", }, List: BlockHTMLRender{ Opener: "<ul>", Closer: "</ul>", CleanContent: true, }, ListItem: BlockHTMLRender{ Opener: "<li>", Closer: "</li>", }, ThematicBreak: BlockHTMLRender{ Opener: "", Closer: "<hr />", CleanContent: true, }, Header1: BlockHTMLRender{ Opener: "<h1>", Closer: "</h1>", }, Header2: BlockHTMLRender{ Opener: "<h2>", Closer: "</h2>", }, Header3: BlockHTMLRender{ Opener: "<h3>", Closer: "</h3>", }, Header4: BlockHTMLRender{ Opener: "<h4>", Closer: "</h4>", }, Header5: BlockHTMLRender{ Opener: "<h5>", Closer: "</h5>", }, Header6: BlockHTMLRender{ Opener: "<h6>", Closer: "</h6>", }, CodeBlock: BlockHTMLRender{ Opener: "<pre><code>", Closer: "</code></pre>", }, }
View Source
var Debug bool
View Source
var InlineHTMLTags map[InlineObjectType]InlineHTMLTagset = map[InlineObjectType]InlineHTMLTagset{ StrongText: InlineHTMLTagset{ Opener: func(i *InlineTag) string { return "<strong>" }, Closer: func(i *InlineTag) string { return "</strong>" }, OpLen: func(i *InlineTag) int { return 2 }, }, EmText: InlineHTMLTagset{ Opener: func(i *InlineTag) string { return "<em>" }, Closer: func(i *InlineTag) string { return "</em>" }, OpLen: func(i *InlineTag) int { return 1 }, }, CodeSpan: InlineHTMLTagset{ Opener: func(i *InlineTag) string { return "<code>" }, Closer: func(i *InlineTag) string { return "</code>" }, OpLen: func(i *InlineTag) int { return 1 }, }, LinkRef: InlineHTMLTagset{ Opener: func(i *InlineTag) string { return "<a href=\"" + i.Content[1] + "\">" }, Closer: func(i *InlineTag) string { return "</a>" }, OpLen: func(i *InlineTag) int { return 1 }, }, Link: InlineHTMLTagset{ Opener: func(i *InlineTag) string { return "" }, Closer: func(i *InlineTag) string { return "" }, OpLen: func(i *InlineTag) int { if i.Tag == Opener { return len(i.Content[0]) + 2 } return 0 }, }, ImageRef: InlineHTMLTagset{ Opener: func(i *InlineTag) string { return "<img src=\"" + i.Content[1] + "\">" }, Closer: func(i *InlineTag) string { return "" }, OpLen: func(i *InlineTag) int { if i.Tag == Opener { return 2 } return 1 + len(i.Content[0]) }, }, Image: InlineHTMLTagset{ Opener: func(i *InlineTag) string { return "" }, Closer: func(i *InlineTag) string { return "" }, OpLen: func(i *InlineTag) int { if i.Tag == Opener { return len(i.Content[0]) + 2 } return 0 }, }, LineBreak: InlineHTMLTagset{ Opener: func(i *InlineTag) string { return "<br>" }, Closer: func(i *InlineTag) string { return "" }, OpLen: func(i *InlineTag) int { if len(i.Content) > 0 && i.Tag == Opener { return 1 } return 0 }, }, }
Functions ¶
func NewDocumentConstructor ¶ added in v0.1.1
Types ¶
type BlockHTMLRender ¶
type BlockObject ¶
type BlockObject struct { Type BlockObjectType Initialized bool // indicates if a block object is currently being initalized or not Content string // the content of a block object, in string format. This is the raw string parsed by a constructor. Inlines []*InlineObject // whatever inline objects a block object may have Blocks []*BlockObject // some blocks can contain more blocks - if so, then a blockobject will contain these blocks. }
func NewBlockObject ¶
func NewBlockObject(t BlockObjectType, i bool) *BlockObject
func NewGeneric ¶
func NewGeneric() *BlockObject
func NewHeader ¶
func NewHeader() *BlockObject
func NewListItem ¶
func NewListItem() *BlockObject
func NewParagraph ¶
func NewParagraph() *BlockObject
func NewThematicBreak ¶
func NewThematicBreak() *BlockObject
func (*BlockObject) GetListAttrib ¶
func (b *BlockObject) GetListAttrib() ListAttribs
listOffsets are encoded in the List's content as fieldless CSV
type BlockObjectRender ¶
type BlockObjectRender struct { Object *BlockObject Offset int Render string // contains filtered or unexported fields }
type BlockObjectType ¶
type BlockObjectType int
const ( Generic BlockObjectType = iota // generics are placeholders Paragraph Header1 Header2 Header3 Header4 Header5 Header6 ThematicBreak List ListItem CodeBlock )
type Document ¶
type Document struct {
Content []*BlockObject // A document is comprised of only blocks - so, this makes sense for accessing.
}
type InlineContent ¶
type InlineHTMLTag ¶
type InlineHTMLTagset ¶
type InlineHTMLTagset struct { Opener InlineHTMLTag Closer InlineHTMLTag OpLen InlineOpLen }
type InlineObject ¶
type InlineObject struct { Type InlineObjectType StartPos int // indicates the current starting position of the object relative to content EndPos int // indicates the ending position of the object relative to content Content []string Closer Specials // returns whatever closes the inline object }
InlineObject represents an inline object within a block object. It consists of several things: - A start position, which indicates where in the content it should start - An end position, which indicates where in the content it should end.
Inline objects can be several types of things (bold, URL, emphasis, etc), so it is a method interface.
func NewEmText ¶
func NewEmText(p int) *InlineObject
func NewGenericInline ¶
func NewGenericInline(p int) *InlineObject
func NewInline ¶
func NewInline(p int, t InlineObjectType) *InlineObject
func NewStrongText ¶
func NewStrongText(p int) *InlineObject
type InlineObjectType ¶
type InlineObjectType int
const ( GenericInline InlineObjectType = iota StrongText LineBreak EmText LinkRef Link ImageRef Image CodeSpan )
type InlineOpLen ¶
type InlineSort ¶
type InlineSort struct{ InlineTags }
func (InlineSort) Less ¶
func (s InlineSort) Less(i, j int) bool
type InlineTag ¶
type InlineTag struct { Type InlineObjectType Content []string Tag InlineTagType Pos int }
type InlineTagType ¶
type InlineTagType int
const ( Opener InlineTagType = 0 Closer InlineTagType = 1 )
type InlineTags ¶
type InlineTags []*InlineTag
func (InlineTags) Len ¶
func (t InlineTags) Len() int
func (InlineTags) Swap ¶
func (t InlineTags) Swap(i, j int)
type ListAttribs ¶
type SpecialAction ¶
Click to show internal directories.
Click to hide internal directories.