types

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 2, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AttrID the key to retrieve the ID in the element attributes
	AttrID string = "id"
	// AttrTitle the key to retrieve the title in the element attributes
	AttrTitle string = "title"
	// AttrRole the key to retrieve the role in the element attributes
	AttrRole string = "role"
	// AttrInlineLink the key to retrieve the link in the element attributes
	AttrInlineLink string = "link"
	// AttrAdmonitionKind the key to retrieve the kind of admonition in the element attributes, if a "masquerade" is used
	AttrAdmonitionKind string = "admonitionKind"
	// AttrQuoteAuthor attribute for the author of a verse
	AttrQuoteAuthor string = "quoteAuthor"
	// AttrQuoteTitle attribute for the title of a verse
	AttrQuoteTitle string = "quoteTitle"
	// AttrSource the "source" attribute for a source block or a source paragraph (this is a placeholder, ie, it does not expect any value for this attribute)
	AttrSource string = "source"
	// AttrLanguage the associated "language" attribute for a source block or a source paragraph
	AttrLanguage string = "language"
)
View Source
const (
	// AttrKind the key for the kind of block
	AttrKind string = "kind"
	// Fenced a fenced block
	Fenced BlockKind = iota // 1
	// Listing a listing block
	Listing
	// Example an example block
	Example
	// Comment a comment block
	Comment
	// Quote a quote block
	Quote
	// Verse a verse block
	Verse
	// Sidebar a sidebar block
	Sidebar
	// Literal a literal block
	Literal
	// Source a source block
	Source
)
View Source
const (
	// AttrImageAlt the image `alt` attribute
	AttrImageAlt string = "alt"
	// AttrImageWidth the image `width` attribute
	AttrImageWidth string = "width"
	// AttrImageHeight the image `height` attribute
	AttrImageHeight string = "height"
	// AttrImageTitle the image `title` attribute
	AttrImageTitle string = "title"
)
View Source
const (
	// AttrLiteralBlockType the type of literal block, ie, how it was parsed
	AttrLiteralBlockType = "literalBlockType"
	// LiteralBlockWithDelimiter a literal block parsed with a delimiter
	LiteralBlockWithDelimiter = "literalBlockWithDelimiter"
	// LiteralBlockWithSpacesOnFirstLine a literal block parsed with one or more spaces on the first line
	LiteralBlockWithSpacesOnFirstLine = "literalBlockWithSpacesOnFirstLine"
	// LiteralBlockWithAttribute a literal block parsed with a `[literal]` attribute`
	LiteralBlockWithAttribute = "literalBlockWithAttribute"
)
View Source
const AttrHardBreaks = "%hardbreaks"

AttrHardBreaks the attribute to set on a paragraph to render with hard breaks on each line

View Source
const AttrInlineLinkText string = "text"

AttrInlineLinkText the link `text` attribute

View Source
const DocumentAttrHardBreaks = "hardbreaks"

DocumentAttrHardBreaks the attribute to set at the document level to render with hard breaks on each line of all paragraphs

Variables

This section is empty.

Functions

func NewEscapedQuotedText

func NewEscapedQuotedText(backslashes string, punctuation string, content []interface{}) ([]interface{}, error)

NewEscapedQuotedText returns a new InlineElements where the nested elements are preserved (ie, substituted as expected)

func NewListItemContent

func NewListItemContent(content []interface{}) ([]interface{}, error)

NewListItemContent initializes a new `UnorderedListItemContent`

func NewQuoteAttributes

func NewQuoteAttributes(kind, author, title string) (map[string]interface{}, error)

NewQuoteAttributes initializes a new map of attributes for a verse paragraph

func None

func None(content []interface{}) ([]interface{}, error)

None returns the content as-is, but nil-safe

func ResetFootnoteSequence

func ResetFootnoteSequence()

ResetFootnoteSequence resets the footnote sequence (for test purpose only)

func Verbatim

func Verbatim(content []interface{}) ([]interface{}, error)

Verbatim the verbatim substitution: the given content is converted into an array of strings.

func WithAttributes

func WithAttributes(element interface{}, attributes []interface{}) (interface{}, error)

WithAttributes set the attributes on the given elements if its type is supported, otherwise returns an error

Types

type AdmonitionKind

type AdmonitionKind string

AdmonitionKind the type of admonition

const (
	// Tip the 'TIP' type of admonition
	Tip AdmonitionKind = "tip"
	// Note the 'NOTE' type of admonition
	Note AdmonitionKind = "note"
	// Important the 'IMPORTANT' type of admonition
	Important AdmonitionKind = "important"
	// Warning the 'WARNING' type of admonition
	Warning AdmonitionKind = "warning"
	// Caution the 'CAUTION' type of admonition
	Caution AdmonitionKind = "caution"
	// Unknown is the zero value for admonition kind
	Unknown AdmonitionKind = ""
)

type BlankLine

type BlankLine struct {
}

BlankLine the structure for the empty lines, which are used to separate logical blocks

func NewBlankLine

func NewBlankLine() (BlankLine, error)

NewBlankLine initializes a new `BlankLine`

func (BlankLine) AddAttributes

func (l BlankLine) AddAttributes(attributes ElementAttributes)

AddAttributes adds all given attributes to the current set of attribute of the element

type BlockKind

type BlockKind int

BlockKind the kind of block

type BulletStyle

type BulletStyle string

BulletStyle the type of bullet for items in an unordered list

const (
	// UnknownBulletStyle the default, unknown type
	UnknownBulletStyle BulletStyle = "unkwown"
	// Dash an unordered item can begin with a single dash
	Dash BulletStyle = "dash"
	// OneAsterisk an unordered item marked with a single asterisk
	OneAsterisk BulletStyle = "1asterisk"
	// TwoAsterisks an unordered item marked with two asterisks
	TwoAsterisks BulletStyle = "2asterisks"
	// ThreeAsterisks an unordered item marked with three asterisks
	ThreeAsterisks BulletStyle = "3asterisks"
	// FourAsterisks an unordered item marked with four asterisks
	FourAsterisks BulletStyle = "4asterisks"
	// FiveAsterisks an unordered item marked with five asterisks
	FiveAsterisks BulletStyle = "5asterisks"
)

type CrossReference

type CrossReference struct {
	ID    string
	Label string
}

CrossReference the struct for Cross References

func NewCrossReference

func NewCrossReference(id string, label interface{}) (CrossReference, error)

NewCrossReference initializes a new `CrossReference` from the given ID

type DefaultAttribute

type DefaultAttribute func(map[string]interface{})

DefaultAttribute a function to specify a default attribute

func WithNumberingStyle

func WithNumberingStyle(t NumberingStyle) DefaultAttribute

WithNumberingStyle specifies the numbering type in an OrderedList

type DelimitedBlock

type DelimitedBlock struct {
	Attributes ElementAttributes
	Elements   []interface{}
}

DelimitedBlock the structure for the delimited blocks

func NewDelimitedBlock

func NewDelimitedBlock(kind BlockKind, content []interface{}, substitution Substitution, attributes ...interface{}) (DelimitedBlock, error)

NewDelimitedBlock initializes a new `DelimitedBlock` of the given kind with the given content

func (DelimitedBlock) AddAttributes

func (b DelimitedBlock) AddAttributes(attributes ElementAttributes)

AddAttributes adds all given attributes to the current set of attribute of the element

type Document

type Document struct {
	Attributes         DocumentAttributes
	Elements           []interface{}
	ElementReferences  ElementReferences
	Footnotes          Footnotes
	FootnoteReferences FootnoteReferences
}

Document the top-level structure for a document

func NewDocument

func NewDocument(frontmatter, header interface{}, blocks []interface{}) (Document, error)

NewDocument initializes a new `Document` from the given lines

type DocumentAttributeDeclaration

type DocumentAttributeDeclaration struct {
	Name  string
	Value string
}

DocumentAttributeDeclaration the type for Document Attribute Declarations

func NewDocumentAttributeDeclaration

func NewDocumentAttributeDeclaration(name string, value interface{}) (DocumentAttributeDeclaration, error)

NewDocumentAttributeDeclaration initializes a new DocumentAttributeDeclaration with the given name and optional value

func (DocumentAttributeDeclaration) AddAttributes

func (d DocumentAttributeDeclaration) AddAttributes(attributes ElementAttributes)

AddAttributes adds all given attributes to the current set of attribute of the element

type DocumentAttributeReset

type DocumentAttributeReset struct {
	Name string
}

DocumentAttributeReset the type for DocumentAttributeReset

func NewDocumentAttributeReset

func NewDocumentAttributeReset(attrName string) (DocumentAttributeReset, error)

NewDocumentAttributeReset initializes a new Document Attribute Resets.

func (DocumentAttributeReset) AddAttributes

func (r DocumentAttributeReset) AddAttributes(attributes ElementAttributes)

AddAttributes adds all given attributes to the current set of attribute of the element

type DocumentAttributeSubstitution

type DocumentAttributeSubstitution struct {
	Name string
}

DocumentAttributeSubstitution the type for DocumentAttributeSubstitution

func NewDocumentAttributeSubstitution

func NewDocumentAttributeSubstitution(attrName string) (DocumentAttributeSubstitution, error)

NewDocumentAttributeSubstitution initializes a new Document Attribute Substitutions

type DocumentAttributes

type DocumentAttributes map[string]interface{}

DocumentAttributes the document attributes

func (DocumentAttributes) Add

func (a DocumentAttributes) Add(key string, value interface{})

Add adds the given attribute if its value is non-nil TODO: raise a warning if there was already a name/value

func (DocumentAttributes) AddAttribute

func (a DocumentAttributes) AddAttribute(attr DocumentAttributeDeclaration)

AddAttribute adds the given attribute TODO: raise a warning if there was already a name/value

func (DocumentAttributes) AddNonEmpty

func (a DocumentAttributes) AddNonEmpty(key string, value interface{})

AddNonEmpty adds the given attribute if its value is non-nil and non-empty TODO: raise a warning if there was already a name/value

func (DocumentAttributes) GetAsString

func (a DocumentAttributes) GetAsString(key string) string

GetAsString gets the string value for the given key, or nil if none was found

func (DocumentAttributes) GetTOCLevels

func (a DocumentAttributes) GetTOCLevels() (*int, error)

GetTOCLevels returns the value of the `toclevels` attribute if it was specified, or `2` as the default value

func (DocumentAttributes) GetTitle

func (a DocumentAttributes) GetTitle() (SectionTitle, error)

GetTitle retrieves the document title in its metadata, or returns nil if the title was not specified

func (DocumentAttributes) Has

func (a DocumentAttributes) Has(key string) bool

Has returns the true if an entry with the given key exists

func (DocumentAttributes) HasAuthors

func (a DocumentAttributes) HasAuthors() bool

HasAuthors returns `true` if the document has one or more authors, `false` otherwise.

func (DocumentAttributes) Reset

Reset resets the given attribute

type DocumentAuthor

type DocumentAuthor struct {
	FullName   string
	Initials   string
	FirstName  string
	MiddleName string
	LastName   string
	Email      string
}

DocumentAuthor a document author

func NewDocumentAuthor

func NewDocumentAuthor(namePart1, namePart2, namePart3, emailAddress interface{}) (DocumentAuthor, error)

NewDocumentAuthor initializes a new DocumentAuthor

func NewDocumentAuthors

func NewDocumentAuthors(authors []interface{}) ([]DocumentAuthor, error)

NewDocumentAuthors converts the given authors into an array of `DocumentAuthor`

func (*DocumentAuthor) String

func (a *DocumentAuthor) String() string

type DocumentElement

type DocumentElement interface {
	AddAttributes(attributes ElementAttributes)
}

DocumentElement an element on which attributes can be added/set

type DocumentHeader

type DocumentHeader struct {
	Content DocumentAttributes
}

DocumentHeader the document header

func NewDocumentHeader

func NewDocumentHeader(header, authors, revision interface{}, otherAttributes []interface{}) (DocumentHeader, error)

NewDocumentHeader initializes a new DocumentHeader

type DocumentRevision

type DocumentRevision struct {
	Revnumber string
	Revdate   string
	Revremark string
}

DocumentRevision a document revision

func NewDocumentRevision

func NewDocumentRevision(revnumber, revdate, revremark interface{}) (DocumentRevision, error)

NewDocumentRevision intializes a new DocumentRevision

func (DocumentRevision) String

func (r DocumentRevision) String() string

type ElementAttributes

type ElementAttributes map[string]interface{}

ElementAttributes is a map[string]interface{} with some utility methods

func NewAdmonitionAttribute

func NewAdmonitionAttribute(k AdmonitionKind) (ElementAttributes, error)

NewAdmonitionAttribute initializes a new attribute map with a single entry for the admonition kind using the given value

func NewAttributeGroup

func NewAttributeGroup(attributes []interface{}) (ElementAttributes, error)

NewAttributeGroup initializes a group of attributes from the given generic attributes.

func NewElementAttributes

func NewElementAttributes(attributes []interface{}, extras ...ElementAttributes) ElementAttributes

NewElementAttributes retrieves the ElementID, ElementTitle and ElementInlineLink from the given slice of attributes

func NewElementID

func NewElementID(id string) (ElementAttributes, error)

NewElementID initializes a new attribute map with a single entry for the ID using the given value

func NewElementRole

func NewElementRole(role string) (ElementAttributes, error)

NewElementRole initializes a new attribute map with a single entry for the title using the given value

func NewElementTitle

func NewElementTitle(title string) (ElementAttributes, error)

NewElementTitle initializes a new attribute map with a single entry for the title using the given value

func NewGenericAttribute

func NewGenericAttribute(key string, value interface{}) (ElementAttributes, error)

NewGenericAttribute initializes a new ElementAttribute from the given key and optional value

func NewImageAttributes

func NewImageAttributes(alt, width, height interface{}, otherAttrs []interface{}) (ElementAttributes, error)

NewImageAttributes returns a map of image attributes, some of which have implicit keys (`alt`, `width` and `height`)

func NewInlineElementID

func NewInlineElementID(id string) (ElementAttributes, error)

NewInlineElementID initializes a new attribute map with a single entry for the ID using the given value

func NewInlineLinkAttributes

func NewInlineLinkAttributes(text interface{}, otherAttrs []interface{}) (ElementAttributes, error)

NewInlineLinkAttributes returns a map of image attributes, some of which have implicit keys (`text`)

func NewLiteralAttribute

func NewLiteralAttribute() (ElementAttributes, error)

NewLiteralAttribute initializes a new attribute map with a single entry for the literal kind of block

func NewSourceAttributes

func NewSourceAttributes(language string) (ElementAttributes, error)

NewSourceAttributes initializes a new attribute map with two entries, one for the kind of element ("source") and another optional one for the language of the source code

func (ElementAttributes) AddAll

func (a ElementAttributes) AddAll(attributes ElementAttributes)

AddAll adds all the given attributes to the current ones

func (ElementAttributes) GetAsString

func (a ElementAttributes) GetAsString(key string) string

GetAsString returns the value of the key as a string, or empty string if the key did not exist

func (ElementAttributes) Has

func (a ElementAttributes) Has(key string) bool

Has returns the true if an entry with the given key exists

type ElementReferences

type ElementReferences map[string]interface{}

ElementReferences the element references in the document

type ElementReferencesCollector

type ElementReferencesCollector struct {
	ElementReferences ElementReferences
}

ElementReferencesCollector the visitor that traverses the whole document structure in search for elements with an ID

func NewElementReferencesCollector

func NewElementReferencesCollector() *ElementReferencesCollector

NewElementReferencesCollector initializes a new ElementReferencesCollector

func (*ElementReferencesCollector) Visit

func (c *ElementReferencesCollector) Visit(element Visitable) error

Visit Implements Visitable#Visit()

type Footnote

type Footnote struct {
	ID int
	// Ref the optional reference
	Ref string
	// the footnote content (can be "rich")
	Elements InlineElements
}

Footnote a foot note, without or without explicit reference (an explicit reference is used to refer multiple times to the same footnote across the document)

func NewFootnote

func NewFootnote(ref string, elements InlineElements) (Footnote, error)

NewFootnote returns a new Footnote with the given content

func (Footnote) Accept

func (f Footnote) Accept(v Visitor) error

Accept implements Visitable#Accept(Visitor)

type FootnoteReferences

type FootnoteReferences map[string]Footnote

FootnoteReferences some footnote have a ref to be re-used in the document

type Footnotes

type Footnotes []Footnote

Footnotes the footnotes of a document. Footnotes are "collected" during the parsing phase and displayed at the bottom of the document during the rendering.

func (Footnotes) IndexOf

func (f Footnotes) IndexOf(note Footnote) (int, bool)

IndexOf returns the index of the given note in the footnotes.

type FootnotesCollector

type FootnotesCollector struct {
	Footnotes          Footnotes
	FootnoteReferences FootnoteReferences
}

FootnotesCollector the visitor that traverses the whole document structure in search for footnotes

func NewFootnotesCollector

func NewFootnotesCollector() *FootnotesCollector

NewFootnotesCollector initializes a new FootnotesCollector

func (*FootnotesCollector) Visit

func (c *FootnotesCollector) Visit(element Visitable) error

Visit Implements Visitable#Visit()

type FrontMatter

type FrontMatter struct {
	Content map[string]interface{}
}

FrontMatter the structure for document front-matter

func NewYamlFrontMatter

func NewYamlFrontMatter(content string) (FrontMatter, error)

NewYamlFrontMatter initializes a new FrontMatter from the given `content`

type ImageBlock

type ImageBlock struct {
	Path       string
	Attributes ElementAttributes
}

ImageBlock the structure for the block images

func NewImageBlock

func NewImageBlock(path string, inlineAttributes ElementAttributes) (ImageBlock, error)

NewImageBlock initializes a new `ImageBlock`

func (ImageBlock) AddAttributes

func (i ImageBlock) AddAttributes(attributes ElementAttributes)

AddAttributes adds all given attributes to the current set of attribute of the element

type ImageMacro

type ImageMacro struct {
	Path       string
	Attributes ElementAttributes
}

ImageMacro the structure for the block image macros

func NewImageMacro

func NewImageMacro(path string, attributes ElementAttributes) (ImageMacro, error)

NewImageMacro initializes a new `ImageMacro`

type InlineElements

type InlineElements []interface{}

InlineElements the structure for the lines in paragraphs

func NewInlineElements

func NewInlineElements(elements ...interface{}) (InlineElements, error)

NewInlineElements initializes a new `InlineElements` from the given values

func (InlineElements) Accept

func (e InlineElements) Accept(v Visitor) error

Accept implements Visitable#Accept(Visitor)

type InlineImage

type InlineImage struct {
	Path       string
	Attributes ElementAttributes
}

InlineImage the structure for the inline image macros

func NewInlineImage

func NewInlineImage(path string, attributes ElementAttributes) (InlineImage, error)

NewInlineImage initializes a new `InlineImage` (similar to ImageBlock, but without attributes)

func (InlineImage) AddAttributes

func (i InlineImage) AddAttributes(attributes ElementAttributes)

AddAttributes adds all given attributes to the current set of attribute of the element

type InlineLink struct {
	URL        string
	Attributes ElementAttributes
}

InlineLink the structure for the external links

func NewInlineLink(url string, attributes interface{}) (InlineLink, error)

NewInlineLink initializes a new inline `InlineLink`

func (InlineLink) Text

func (l InlineLink) Text() string

Text returns the `text` value for the InlineLink,

type LabeledList

type LabeledList struct {
	Attributes ElementAttributes
	Items      []LabeledListItem
}

LabeledList the structure for the Labeled Lists

func (LabeledList) AddAttributes

func (l LabeledList) AddAttributes(attributes ElementAttributes)

AddAttributes adds all given attributes to the current set of attribute of the element

type LabeledListItem

type LabeledListItem struct {
	Term       string
	Level      int
	Attributes ElementAttributes
	Elements   []interface{}
}

LabeledListItem an item in a labeled

func NewLabeledListItem

func NewLabeledListItem(level int, term string, elements []interface{}) (LabeledListItem, error)

NewLabeledListItem initializes a new LabeledListItem

func (*LabeledListItem) AddAttributes

func (i *LabeledListItem) AddAttributes(attributes ElementAttributes)

AddAttributes adds all given attributes to the current set of attribute of the element

func (*LabeledListItem) AddChild

func (i *LabeledListItem) AddChild(item interface{})

AddChild appends the given item to the content of this LabeledListItem

type LineBreak

type LineBreak struct{}

LineBreak an explicit line break in a paragraph

func NewLineBreak

func NewLineBreak() (LineBreak, error)

NewLineBreak returns a new line break, that's all.

type List

type List interface {
}

List a list

func NewList

func NewList(items []interface{}) (List, error)

NewList initializes a new `List` from the given content

type ListItem

type ListItem interface {
	AddChild(interface{})
}

ListItem a list item

type ListItemContinuation

type ListItemContinuation struct {
}

ListItemContinuation a list item continuation

func NewListItemContinuation

func NewListItemContinuation() (ListItemContinuation, error)

NewListItemContinuation returns a new ListItemContinuation

type LiteralBlock

type LiteralBlock struct {
	Attributes ElementAttributes
	Lines      []string
}

LiteralBlock the structure for the literal blocks

func NewLiteralBlock

func NewLiteralBlock(origin string, lines []interface{}, attributes ...interface{}) (LiteralBlock, error)

NewLiteralBlock initializes a new `DelimitedBlock` of the given kind with the given content, along with the given sectionTitle spaces

func (LiteralBlock) AddAttributes

func (b LiteralBlock) AddAttributes(attributes ElementAttributes)

AddAttributes adds all given attributes to the current set of attribute of the element

type NormalizationFunc

type NormalizationFunc func(string) ([]byte, error)

NormalizationFunc a function that is used to normalize a string.

type NumberingStyle

type NumberingStyle string

NumberingStyle the type of numbering for items in an ordered list

const (
	// UnknownNumberingStyle the default, unknown type
	UnknownNumberingStyle NumberingStyle = "unknown"
	// Arabic the arabic numbering (1, 2, 3, etc.)
	Arabic NumberingStyle = "arabic"
	// Decimal the decimal numbering (01, 02, 03, etc.)
	Decimal NumberingStyle = "decimal"
	// LowerAlpha the lower-alpha numbering (a, b, c, etc.)
	LowerAlpha NumberingStyle = "loweralpha"
	// UpperAlpha the upper-alpha numbering (A, B, C, etc.)
	UpperAlpha NumberingStyle = "upperalpha"
	// LowerRoman the lower-roman numbering (i, ii, iii, etc.)
	LowerRoman NumberingStyle = "lowerroman"
	// UpperRoman the upper-roman numbering (I, II, III, etc.)
	UpperRoman NumberingStyle = "upperroman"
	// LowerGreek the lower-greek numbering (alpha, beta, etc.)
	LowerGreek NumberingStyle = "lowergreek"
	// UpperGreek the upper-roman numbering (Alpha, Beta, etc.)
	UpperGreek NumberingStyle = "uppergreek"
)

type OrderedList

type OrderedList struct {
	Attributes ElementAttributes
	Items      []OrderedListItem
}

OrderedList the structure for the Ordered Lists

func (OrderedList) AddAttributes

func (o OrderedList) AddAttributes(attributes ElementAttributes)

AddAttributes adds all given attributes to the current set of attribute of the element

type OrderedListItem

type OrderedListItem struct {
	Level          int
	Position       int
	NumberingStyle NumberingStyle
	Attributes     ElementAttributes
	Elements       []interface{}
}

OrderedListItem the structure for the ordered list items

func NewOrderedListItem

func NewOrderedListItem(prefix OrderedListItemPrefix, elements []interface{}, attributes []interface{}) (OrderedListItem, error)

NewOrderedListItem initializes a new `orderedListItem` from the given content

func (*OrderedListItem) AddAttributes

func (i *OrderedListItem) AddAttributes(attributes ElementAttributes)

AddAttributes adds all given attributes to the current set of attribute of the element

func (*OrderedListItem) AddChild

func (i *OrderedListItem) AddChild(item interface{})

AddChild appends the given item to the content of this OrderedListItem

type OrderedListItemPrefix

type OrderedListItemPrefix struct {
	NumberingStyle NumberingStyle
	Level          int
}

OrderedListItemPrefix the prefix used to construct an OrderedListItem

func NewOrderedListItemPrefix

func NewOrderedListItemPrefix(s NumberingStyle, l int) (OrderedListItemPrefix, error)

NewOrderedListItemPrefix initializes a new OrderedListItemPrefix

type Paragraph

type Paragraph struct {
	Attributes ElementAttributes
	Lines      []InlineElements
}

Paragraph the structure for the paragraphs

func NewAdmonitionParagraph

func NewAdmonitionParagraph(lines []interface{}, admonitionKind AdmonitionKind, attributes ...interface{}) (Paragraph, error)

NewAdmonitionParagraph returns a new Paragraph with an extra admonition attribute

func NewParagraph

func NewParagraph(lines []interface{}, attributes ...interface{}) (Paragraph, error)

NewParagraph initializes a new `Paragraph`

func (Paragraph) Accept

func (p Paragraph) Accept(v Visitor) error

Accept implements Visitable#Accept(Visitor)

func (Paragraph) AddAttributes

func (p Paragraph) AddAttributes(attributes ElementAttributes)

AddAttributes adds all given attributes to the current set of attribute of the element

type Passthrough

type Passthrough struct {
	Kind     PassthroughKind
	Elements InlineElements
}

Passthrough the structure for Passthroughs

func NewPassthrough

func NewPassthrough(kind PassthroughKind, elements []interface{}) (Passthrough, error)

NewPassthrough returns a new passthrough

type PassthroughKind

type PassthroughKind int

PassthroughKind the kind of passthrough

const (
	// SinglePlusPassthrough a passthrough with a single `+` punctuation
	SinglePlusPassthrough PassthroughKind = iota
	// TriplePlusPassthrough a passthrough with a triple `+++` punctuation
	TriplePlusPassthrough
	// PassthroughMacro a passthrough with the `pass:[]` macro
	PassthroughMacro
)

type Preamble

type Preamble struct {
	Elements []interface{}
}

Preamble the structure for document Preamble

func NewEmptyPreamble

func NewEmptyPreamble() Preamble

NewEmptyPreamble return an empty Preamble

func (Preamble) Accept

func (p Preamble) Accept(v Visitor) error

Accept implements Visitable#Accept(Visitor)

type QuotedText

type QuotedText struct {
	Attributes ElementAttributes
	Elements   InlineElements
}

QuotedText the structure for quoted text

func NewQuotedText

func NewQuotedText(kind QuotedTextKind, content []interface{}) (QuotedText, error)

NewQuotedText initializes a new `QuotedText` from the given kind and content

func (QuotedText) Accept

func (t QuotedText) Accept(v Visitor) error

Accept implements Visitable#Accept(Visitor)

type QuotedTextKind

type QuotedTextKind int

QuotedTextKind the type for

const (
	// Bold bold quoted text (wrapped with '*' or '**')
	Bold QuotedTextKind = iota
	// Italic italic quoted text (wrapped with '_' or '__')
	Italic
	// Monospace monospace quoted text (wrapped with '`' or '“')
	Monospace
	// Subscript subscript quoted text (wrapped with '~' or '~~')
	Subscript
	// Superscript superscript quoted text (wrapped with '^' or '^^')
	Superscript
)

type Section

type Section struct {
	Level    int
	Title    SectionTitle
	Elements []interface{}
}

Section the structure for a section

func NewSection

func NewSection(level int, sectionTitle SectionTitle, blocks []interface{}) (Section, error)

NewSection initializes a new `Section` from the given section title and elements

func (Section) Accept

func (s Section) Accept(v Visitor) error

Accept implements Visitable#Accept(Visitor)

func (Section) AddAttributes

func (s Section) AddAttributes(attributes ElementAttributes)

AddAttributes adds all given attributes to the current set of attribute of the element

type SectionTitle

type SectionTitle struct {
	Attributes ElementAttributes
	Elements   InlineElements
}

SectionTitle the structure for the section titles

func NewSectionTitle

func NewSectionTitle(elements InlineElements, ids []interface{}) (SectionTitle, error)

NewSectionTitle initializes a new `SectionTitle“ from the given level and content, with the optional attributes. In the attributes, only the ElementID is retained

func (SectionTitle) Accept

func (st SectionTitle) Accept(v Visitor) error

Accept implements Visitable#Accept(Visitor)

func (SectionTitle) AddAttributes

func (st SectionTitle) AddAttributes(attributes ElementAttributes)

AddAttributes adds all given attributes to the current set of attribute of the element

type SingleLineComment

type SingleLineComment struct {
	Content string
}

SingleLineComment a single line comment

func NewSingleLineComment

func NewSingleLineComment(content string) (SingleLineComment, error)

NewSingleLineComment initializes a new single line content

type StringElement

type StringElement struct {
	Content string
}

StringElement the structure for strings

func NewStringElement

func NewStringElement(content string) StringElement

NewStringElement initializes a new `StringElement` from the given content

func (StringElement) Accept

func (s StringElement) Accept(v Visitor) error

Accept implements Visitable#Accept(Visitor)

type Substitution

type Substitution func([]interface{}) ([]interface{}, error)

Substitution the substitution group to apply when initializing a delimited block

type Table

type Table struct {
	Attributes ElementAttributes
	Header     TableLine
	Lines      []TableLine
}

Table the structure for the tables

func NewTable

func NewTable(header interface{}, lines []interface{}) (Table, error)

NewTable initializes a new table with the given lines and attributes

func (Table) AddAttributes

func (t Table) AddAttributes(attributes ElementAttributes)

AddAttributes adds all given attributes to the current set of attribute of the element

type TableLine

type TableLine struct {
	Cells []InlineElements
}

TableLine a table line is made of columns, each column being a group of InlineElements (to support quoted text, etc.)

func NewTableLine

func NewTableLine(columns []interface{}) (TableLine, error)

NewTableLine initializes a new TableLine with the given columns

type TableOfContentsMacro

type TableOfContentsMacro struct {
}

TableOfContentsMacro the structure for Table of Contents

func (TableOfContentsMacro) AddAttributes

func (m TableOfContentsMacro) AddAttributes(attributes ElementAttributes)

AddAttributes adds all given attributes to the current set of attribute of the element

type UnorderedList

type UnorderedList struct {
	Attributes ElementAttributes
	Items      []UnorderedListItem
}

UnorderedList the structure for the Unordered Lists

func (UnorderedList) AddAttributes

func (l UnorderedList) AddAttributes(attributes ElementAttributes)

AddAttributes adds all given attributes to the current set of attribute of the element

type UnorderedListItem

type UnorderedListItem struct {
	Level       int
	BulletStyle BulletStyle
	Attributes  ElementAttributes
	Elements    []interface{}
}

UnorderedListItem the structure for the unordered list items

func NewUnorderedListItem

func NewUnorderedListItem(prefix UnorderedListItemPrefix, elements []interface{}) (UnorderedListItem, error)

NewUnorderedListItem initializes a new `UnorderedListItem` from the given content

func (*UnorderedListItem) AddAttributes

func (i *UnorderedListItem) AddAttributes(attributes ElementAttributes)

AddAttributes adds all given attributes to the current set of attribute of the element

func (*UnorderedListItem) AddChild

func (i *UnorderedListItem) AddChild(item interface{})

AddChild appends the given item to the content of this UnorderedListItem

type UnorderedListItemPrefix

type UnorderedListItemPrefix struct {
	BulletStyle BulletStyle
	Level       int
}

UnorderedListItemPrefix the prefix used to construct an UnorderedListItem

func NewUnorderedListItemPrefix

func NewUnorderedListItemPrefix(s BulletStyle, l int) (UnorderedListItemPrefix, error)

NewUnorderedListItemPrefix initializes a new UnorderedListItemPrefix

type Visitable

type Visitable interface {
	Accept(Visitor) error
}

Visitable the interface for visitable elements

type Visitor

type Visitor interface {
	Visit(Visitable) error
}

Visitor a visitor that can visit/traverse the interface{} and its children (if applicable)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL