Documentation
¶
Index ¶
- Constants
- Variables
- func Apply(source string, fs ...applyFunc) string
- func Merge(elements ...interface{}) []interface{}
- func NewEscapedQuotedText(backslashes string, punctuation string, content interface{}) ([]interface{}, error)
- func NewInlineElements(elements ...interface{}) ([]interface{}, error)
- func NewListItemContent(content []interface{}) ([]interface{}, error)
- func NewQuoteAttributes(kind string, author, title interface{}) (map[string]interface{}, error)
- func NilSafe(elements []interface{}) []interface{}
- func None(content []interface{}) ([]interface{}, error)
- func ReplaceNonAlphanumerics(elements []interface{}, replacement string) (string, error)
- func Verbatim(content []interface{}) ([]interface{}, error)
- type AdmonitionKind
- type BlankLine
- type BlockKind
- type BulletStyle
- type ConcealedIndexTerm
- type ContinuedListItemElement
- type CurrentRanges
- type CurrentTagRange
- type DelimitedBlock
- type Document
- type DocumentAttributeDeclaration
- type DocumentAttributeReset
- type DocumentAttributeSubstitution
- type DocumentAttributes
- func (a DocumentAttributes) Add(key string, value interface{})
- func (a DocumentAttributes) AddAll(attrs map[string]interface{})
- func (a DocumentAttributes) AddDeclaration(attr DocumentAttributeDeclaration)
- func (a DocumentAttributes) AddNonEmpty(key string, value interface{})
- func (a DocumentAttributes) Delete(attr DocumentAttributeReset)
- func (a DocumentAttributes) GetAsString(key string) (string, bool)
- func (a DocumentAttributes) GetAsStringWithDefault(key, defaultValue string) string
- func (a DocumentAttributes) GetAuthors() []DocumentAuthor
- func (a DocumentAttributes) Has(key string) bool
- type DocumentAttributesWithOverrides
- func (a DocumentAttributesWithOverrides) Add(key string, value interface{})
- func (a DocumentAttributesWithOverrides) AddAll(attrs map[string]interface{})
- func (a DocumentAttributesWithOverrides) All() DocumentAttributes
- func (a DocumentAttributesWithOverrides) Delete(key string)
- func (a DocumentAttributesWithOverrides) GetAsString(key string) (string, bool)
- func (a DocumentAttributesWithOverrides) GetAsStringWithDefault(key, defaultValue string) string
- type DocumentAuthor
- type DocumentElement
- type DocumentRevision
- type DraftDocument
- type ElementAttributes
- func NewAdmonitionAttribute(k AdmonitionKind) (ElementAttributes, error)
- func NewAttributeGroup(attributes []interface{}) (ElementAttributes, error)
- func NewElementAttributes(attributes []interface{}) ElementAttributes
- func NewElementID(id string) (ElementAttributes, error)
- func NewElementRole(role string) (ElementAttributes, error)
- func NewElementTitle(title string) (ElementAttributes, error)
- func NewGenericAttribute(key string, value interface{}) (ElementAttributes, error)
- func NewImageAttributes(alt, width, height interface{}, otherattrs []interface{}) (ElementAttributes, error)
- func NewInlineAttributes(attrs []interface{}) (ElementAttributes, error)
- func NewInlineElementID(id string) (ElementAttributes, error)
- func NewInlineLinkAttributes(text interface{}, otherattrs []interface{}) (ElementAttributes, error)
- func NewLineRangesAttribute(ranges interface{}) (ElementAttributes, error)
- func NewLiteralAttribute() (ElementAttributes, error)
- func NewSourceAttributes(language interface{}, others ...interface{}) (ElementAttributes, error)
- func NewTagRangesAttribute(ranges []interface{}) (ElementAttributes, error)
- func (a ElementAttributes) AddAll(attributes ElementAttributes)
- func (a ElementAttributes) AddNonEmpty(key string, value interface{})
- func (a ElementAttributes) GetAsBool(key string) bool
- func (a ElementAttributes) GetAsString(key string) string
- func (a ElementAttributes) Has(key string) bool
- func (a ElementAttributes) NilSafeSet(key string, value interface{})
- type ElementReferences
- type ElementWithAttributes
- type ExternalCrossReference
- type FileInclusion
- type Footnote
- type FootnoteReference
- type Footnotes
- type FootnotesContainer
- type FrontMatter
- type ImageBlock
- type IncludedFileEndTag
- type IncludedFileLine
- type IncludedFileStartTag
- type IndexTerm
- type InlineImage
- type InlineLink
- type InternalCrossReference
- type LabeledList
- type LabeledListItem
- type LineBreak
- type LineRange
- type LineRanges
- type List
- type ListItem
- type LiteralBlock
- type Location
- type MacroKind
- type Metadata
- type NumberingStyle
- type OrderedList
- type OrderedListItem
- type OrderedListItemPrefix
- type Paragraph
- type Passthrough
- type PassthroughKind
- type Preamble
- type QuotedText
- type QuotedTextKind
- type Section
- type SingleLineComment
- type StringElement
- type Substitution
- type Table
- type TableLine
- type TableOfContents
- type TableOfContentsPlaceHolder
- type TagRange
- type TagRanges
- type ToCSection
- type UnorderedList
- type UnorderedListItem
- type UnorderedListItemCheckStyle
- type UnorderedListItemPrefix
- type UserMacro
Constants ¶
const ( // AttrDocType the "doctype" attribute AttrDocType string = "doctype" // AttrSyntaxHighlighter the attribute to define the syntax highlighter on code source blocks AttrSyntaxHighlighter string = "source-highlighter" // AttrIDPrefix the key to retrieve the ID Prefix AttrIDPrefix string = "idprefix" // DefaultIDPrefix the default ID Prefix DefaultIDPrefix string = "_" // AttrTableOfContents the `toc` attribute at document level AttrTableOfContents string = "toc" // AttrTableOfContentsLevels the document attribute which specifies the number of levels to display in the ToC AttrTableOfContentsLevels string = "toclevels" // AttrNoHeader attribute to disable the rendering of document footer AttrNoHeader string = "noheader" AttrNoFooter string = "nofooter" )
const ( // AttrID the key to retrieve the ID AttrID string = "id" // AttrCustomID the key to retrieve the flag that indicates if the element ID is custom or generated AttrCustomID string = "customID" // AttrTitle the key to retrieve the title AttrTitle string = "title" // AttrAuthors the key to the authors declared after the section level 0 (at the beginning of the doc) AttrAuthors string = "authors" // AttrRevision the key to the revision declared after the section level 0 (at the beginning of the doc) AttrRevision string = "revision" // AttrRole the key to retrieve the role AttrRole string = "role" // AttrInlineLink the key to retrieve the link AttrInlineLink string = "link" // AttrAdmonitionKind the key to retrieve the kind of admonition , 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 `language` attribute for a source block or a source paragraph AttrLanguage string = "language" // AttrLineNums the `linenums` attribute for a source block or a source paragraph AttrLineNums string = "linenums" // AttrCheckStyle the attribute to mark the first element of an unordered list itemd as a checked or not AttrCheckStyle string = "checkstyle" // AttrStart the `start` attribute in an ordered list AttrStart string = "start" // AttrNumberingStyle the numbering style of items in a list AttrNumberingStyle string = "numberingStyle" // AttrQandA the `qanda` attribute for Q&A labeled lists AttrQandA string = "qanda" // AttrLevelOffset the `leveloffset` attribute used in file inclusions AttrLevelOffset string = "leveloffset" // AttrLineRanges the `lines` attribute used in file inclusions AttrLineRanges string = "lines" // AttrTagRanges the `tag`/`tags` attribute used in file inclusions AttrTagRanges string = "tags" // AttrLastUpdated the "last updated" data in the document, i.e., the output/generation time AttrLastUpdated string = "LastUpdated" // 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" )
const ( // AttrKind the key for the kind of block AttrKind string = "kind" // Fenced a fenced block Fenced BlockKind = "fenced" // Listing a listing block Listing BlockKind = "listing" // Example an example block Example BlockKind = "example" // Comment a comment block Comment BlockKind = "comment" // Quote a quote block Quote BlockKind = "quote" // Verse a verse block Verse BlockKind = "verse" // Sidebar a sidebar block Sidebar BlockKind = "sidebar" // Literal a literal block Literal BlockKind = "literal" // Source a source block Source BlockKind = "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" )
const AttrHardBreaks = "%hardbreaks"
AttrHardBreaks the attribute to set on a paragraph to render with hard breaks on each line
const AttrInlineLinkText string = "text"
AttrInlineLinkText the link `text` attribute
const DocumentAttrHardBreaks = "hardbreaks"
DocumentAttrHardBreaks the attribute to set at the document level to render with hard breaks on each line of all paragraphs
const ( // InvalidFootnoteReference a constant to mark the footnote reference as invalid InvalidFootnoteReference int = -1 )
Variables ¶
var Predefined map[string]string
Predefined the predefined document attributes, mainly for special characters
Functions ¶
func Merge ¶ added in v0.3.0
func Merge(elements ...interface{}) []interface{}
Merge merge string elements together
func NewEscapedQuotedText ¶
func NewEscapedQuotedText(backslashes string, punctuation string, content interface{}) ([]interface{}, error)
NewEscapedQuotedText returns a new []interface{} where the nested elements are preserved (ie, substituted as expected)
func NewInlineElements ¶
func NewInlineElements(elements ...interface{}) ([]interface{}, error)
NewInlineElements initializes a new `InlineElements` from the given values
func NewListItemContent ¶
func NewListItemContent(content []interface{}) ([]interface{}, error)
NewListItemContent initializes a new `UnorderedListItemContent`
func NewQuoteAttributes ¶
NewQuoteAttributes initializes a new map of attributes for a verse paragraph
func NilSafe ¶ added in v0.3.0
func NilSafe(elements []interface{}) []interface{}
NilSafe returns a new slice if the given elements is nil, otherwise it returns the given elements
func None ¶
func None(content []interface{}) ([]interface{}, error)
None returns the content as-is, but nil-safe
func ReplaceNonAlphanumerics ¶ added in v0.3.0
ReplaceNonAlphanumerics replace all non alpha numeric characters with the given `replacement`
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 ¶
NewBlankLine initializes a new `BlankLine`
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" )
func (BulletStyle) NextLevel ¶ added in v0.3.0
func (b BulletStyle) NextLevel(p BulletStyle) BulletStyle
NextLevel returns the BulletStyle for the next level: `-` -> `*` `*` -> `**` `**` -> `***` `***` -> `****` `****` -> `*****` `*****` -> `-`
type ConcealedIndexTerm ¶ added in v0.3.0
type ConcealedIndexTerm struct { Term1 interface{} Term2 interface{} Term3 interface{} }
ConcealedIndexTerm a concealed index term, with 1 required and 2 optional terms
func NewConcealedIndexTerm ¶ added in v0.3.0
func NewConcealedIndexTerm(term1, term2, term3 interface{}) (ConcealedIndexTerm, error)
NewConcealedIndexTerm returns a new ConcealedIndexTerm
type ContinuedListItemElement ¶ added in v0.3.0
type ContinuedListItemElement struct { Offset int // the relative ancestor. Should be a negative number Element interface{} }
ContinuedListItemElement a wrapper for an element which should be attached to a list item (same level or an ancestor)
func NewContinuedListItemElement ¶ added in v0.3.0
func NewContinuedListItemElement(offset int, element interface{}) (ContinuedListItemElement, error)
NewContinuedListItemElement returns a wrapper for an element which should be attached to a list item (same level or an ancestor)
type CurrentRanges ¶ added in v0.3.0
type CurrentRanges map[string]*CurrentTagRange
CurrentRanges the current ranges, ie, as they are "discovered" while processing one line at a time in the file to include
type CurrentTagRange ¶ added in v0.3.0
CurrentTagRange a tag range found while processing a document. When the 'start' tag is found, the `EndLine` is still unknown and thus its value is set to `-1`.
type DelimitedBlock ¶
type DelimitedBlock struct { Kind BlockKind Attributes ElementAttributes Elements []interface{} // TODO: rename to `Blocks`? }
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
type Document ¶
type Document struct { Attributes DocumentAttributes Elements []interface{} // TODO: rename to `Blocks`? ElementReferences ElementReferences Footnotes []Footnote }
Document the top-level structure for a document
func (Document) Authors ¶ added in v0.3.0
func (d Document) Authors() ([]DocumentAuthor, bool)
Authors retrieves the document authors from the document header, or empty array if no author was found
func (Document) Header ¶ added in v0.3.0
Header returns the header, i.e., the section with level 0 if it exists as the first element of the document For manpage documents, this also includes the first section (`Name` along with its first paragraph)
func (Document) Revision ¶ added in v0.3.0
func (d Document) Revision() (DocumentRevision, bool)
Revision retrieves the document revision from the document header, or empty array if no revision was found
type DocumentAttributeDeclaration ¶
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
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.
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) AddAll ¶ added in v0.2.0
func (a DocumentAttributes) AddAll(attrs map[string]interface{})
AddAll adds the given attributes
func (DocumentAttributes) AddDeclaration ¶ added in v0.2.0
func (a DocumentAttributes) AddDeclaration(attr DocumentAttributeDeclaration)
AddDeclaration 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) Delete ¶ added in v0.3.0
func (a DocumentAttributes) Delete(attr DocumentAttributeReset)
Delete deletes the given attribute
func (DocumentAttributes) GetAsString ¶
func (a DocumentAttributes) GetAsString(key string) (string, bool)
GetAsString gets the string value for the given key (+ `true`), or empty string (+ `false`) if none was found TODO: raise a warning if there was no entry found
func (DocumentAttributes) GetAsStringWithDefault ¶ added in v0.3.0
func (a DocumentAttributes) GetAsStringWithDefault(key, defaultValue string) string
GetAsStringWithDefault gets the string value for the given key, or returns the given default value TODO: raise a warning if there was no entry found
func (DocumentAttributes) GetAuthors ¶ added in v0.4.0
func (a DocumentAttributes) GetAuthors() []DocumentAuthor
GetAuthors returns the authors or empty slice if none was set in the document
func (DocumentAttributes) Has ¶
func (a DocumentAttributes) Has(key string) bool
Has returns the true if an entry with the given key exists
type DocumentAttributesWithOverrides ¶ added in v0.3.0
type DocumentAttributesWithOverrides struct { Content map[string]interface{} Overrides map[string]string }
DocumentAttributesWithOverrides the document attributes with some overrides provided by the CLI (for example)
func (DocumentAttributesWithOverrides) Add ¶ added in v0.3.0
func (a DocumentAttributesWithOverrides) Add(key string, value interface{})
Add add the given attribute
func (DocumentAttributesWithOverrides) AddAll ¶ added in v0.3.0
func (a DocumentAttributesWithOverrides) AddAll(attrs map[string]interface{})
AddAll adds the given attributes
func (DocumentAttributesWithOverrides) All ¶ added in v0.4.0
func (a DocumentAttributesWithOverrides) All() DocumentAttributes
All returns all attributes
func (DocumentAttributesWithOverrides) Delete ¶ added in v0.3.0
func (a DocumentAttributesWithOverrides) Delete(key string)
Delete deletes the given attribute
func (DocumentAttributesWithOverrides) GetAsString ¶ added in v0.3.0
func (a DocumentAttributesWithOverrides) GetAsString(key string) (string, bool)
GetAsString gets the string value for the given key (+ `true`), or empty string (+ `false`) if none was found
func (DocumentAttributesWithOverrides) GetAsStringWithDefault ¶ added in v0.3.0
func (a DocumentAttributesWithOverrides) GetAsStringWithDefault(key, defaultValue string) string
GetAsStringWithDefault gets the string value for the given key, or returns the given default value
type DocumentAuthor ¶
DocumentAuthor a document author
func NewDocumentAuthor ¶
func NewDocumentAuthor(fullName, email 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`
type DocumentElement ¶
type DocumentElement interface {
GetAttributes() ElementAttributes
}
DocumentElement a document element can have attributes
type DocumentRevision ¶
DocumentRevision a document revision
func NewDocumentRevision ¶
func NewDocumentRevision(revnumber, revdate, revremark interface{}) (DocumentRevision, error)
NewDocumentRevision intializes a new DocumentRevision
type DraftDocument ¶ added in v0.3.0
type DraftDocument struct { FrontMatter FrontMatter Blocks []interface{} }
DraftDocument the linear-level structure for a document
func NewDraftDocument ¶ added in v0.3.0
func NewDraftDocument(frontMatter interface{}, blocks []interface{}) (DraftDocument, error)
NewDraftDocument initializes a new Draft`Document` from the given lines
func (DraftDocument) DocumentAttributes ¶ added in v0.3.0
func (d DraftDocument) DocumentAttributes() DocumentAttributes
DocumentAttributes returns the document attributes on the top-level section and all the document attribute declarations at the top of the document only.
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{}) 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 NewInlineAttributes ¶ added in v0.3.0
func NewInlineAttributes(attrs []interface{}) (ElementAttributes, error)
NewInlineAttributes returns a map of attributes
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 link attributes, some of which have implicit keys (`text`)
func NewLineRangesAttribute ¶ added in v0.3.0
func NewLineRangesAttribute(ranges interface{}) (ElementAttributes, error)
NewLineRangesAttribute returns an element attribute with a slice of line ranges attribute for a file inclusion.
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 interface{}, others ...interface{}) (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 NewTagRangesAttribute ¶ added in v0.3.0
func NewTagRangesAttribute(ranges []interface{}) (ElementAttributes, error)
NewTagRangesAttribute returns an element attribute with a slice of tag ranges attribute for a file inclusion.
func (ElementAttributes) AddAll ¶
func (a ElementAttributes) AddAll(attributes ElementAttributes)
AddAll adds all the given attributes to the current ones
func (ElementAttributes) AddNonEmpty ¶ added in v0.4.0
func (a ElementAttributes) 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 (ElementAttributes) GetAsBool ¶ added in v0.2.0
func (a ElementAttributes) GetAsBool(key string) bool
GetAsBool returns the value of the key as a bool, or `false` if the key did not exist or if its value was not a bool
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
func (ElementAttributes) NilSafeSet ¶ added in v0.3.0
func (a ElementAttributes) NilSafeSet(key string, value interface{})
NilSafeSet sets the key/value pair unless the value is nil or empty
type ElementReferences ¶
type ElementReferences map[string]interface{}
ElementReferences the element references in the document
type ElementWithAttributes ¶ added in v0.2.0
type ElementWithAttributes interface {
AddAttributes(attributes ElementAttributes)
}
ElementWithAttributes an element on which attributes can be added/set
type ExternalCrossReference ¶ added in v0.3.0
type ExternalCrossReference struct { Location Location Label []interface{} }
ExternalCrossReference the struct for Cross References
func NewExternalCrossReference ¶ added in v0.3.0
func NewExternalCrossReference(location Location, attributes ElementAttributes) (ExternalCrossReference, error)
NewExternalCrossReference initializes a new `InternalCrossReference` from the given ID
func (ExternalCrossReference) ResolveLocation ¶ added in v0.3.0
func (r ExternalCrossReference) ResolveLocation(attrs DocumentAttributesWithOverrides) ExternalCrossReference
ResolveLocation resolves the image path using the given document attributes also, updates the `alt` attribute based on the resolved path of the image
type FileInclusion ¶ added in v0.3.0
type FileInclusion struct { Attributes ElementAttributes Location Location RawText string }
FileInclusion the structure for the file inclusions
func NewFileInclusion ¶ added in v0.3.0
func NewFileInclusion(location Location, attributes interface{}, rawtext string) (FileInclusion, error)
NewFileInclusion initializes a new inline `InlineLink`
func (*FileInclusion) LineRanges ¶ added in v0.3.0
func (f *FileInclusion) LineRanges() (LineRanges, bool)
LineRanges returns the line ranges of the file to include.
func (*FileInclusion) TagRanges ¶ added in v0.3.0
func (f *FileInclusion) TagRanges() (TagRanges, bool)
TagRanges returns the tag ranges of the file to include.
type Footnote ¶
type Footnote struct { // ID is only set during document processing ID int // Ref the optional reference Ref string // the footnote content (can be "rich") Elements []interface{} }
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 ¶
NewFootnote returns a new Footnote with the given content
type FootnoteReference ¶ added in v0.4.0
type FootnoteReference struct { ID int Ref string // the user-specified reference (optional) Duplicate bool // indicates if this reference targets an already-existing footnote // TODO: find a better name? }
FootnoteReference a footnote reference. Replaces the actual footnote in the document, and only contains a generated, sequential ID (which will be displayed)
type Footnotes ¶
type Footnotes struct {
// contains filtered or unexported fields
}
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 NewFootnotes ¶ added in v0.4.0
func NewFootnotes() *Footnotes
NewFootnotes initializes a new Footnotes
func (*Footnotes) Reference ¶ added in v0.4.0
func (f *Footnotes) Reference(note Footnote) FootnoteReference
Reference adds the given footnote and returns a FootnoteReference in replacement
type FootnotesContainer ¶ added in v0.3.0
type FootnotesContainer interface {
ReplaceFootnotes(existing *Footnotes) interface{}
}
FootnotesContainer interface for all types which may contain footnotes
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 { Location Location Attributes ElementAttributes }
ImageBlock the structure for the block images
func NewImageBlock ¶
func NewImageBlock(path Location, inlineAttributes ElementAttributes, attributes interface{}) (ImageBlock, error)
NewImageBlock initializes a new `ImageBlock`
func (ImageBlock) ResolveLocation ¶ added in v0.3.0
func (b ImageBlock) ResolveLocation(attrs DocumentAttributesWithOverrides) ImageBlock
ResolveLocation resolves the image path using the given document attributes also, updates the `alt` attribute based on the resolved path of the image
type IncludedFileEndTag ¶ added in v0.3.0
type IncludedFileEndTag struct {
Value string
}
IncludedFileEndTag the type for the `end::` macro
func NewIncludedFileEndTag ¶ added in v0.3.0
func NewIncludedFileEndTag(tag string) (IncludedFileEndTag, error)
NewIncludedFileEndTag returns a new IncludedFileEndTag
type IncludedFileLine ¶ added in v0.3.0
type IncludedFileLine []interface{}
IncludedFileLine a line, containing raw text and inclusion tags
func NewIncludedFileLine ¶ added in v0.3.0
func NewIncludedFileLine(content []interface{}) (IncludedFileLine, error)
NewIncludedFileLine returns a new IncludedFileLine
func (IncludedFileLine) GetEndTag ¶ added in v0.3.0
func (l IncludedFileLine) GetEndTag() (IncludedFileEndTag, bool)
GetEndTag returns the first IncludedFileEndTag found in the line // TODO: support multiple tags on the same line ?
func (IncludedFileLine) GetStartTag ¶ added in v0.3.0
func (l IncludedFileLine) GetStartTag() (IncludedFileStartTag, bool)
GetStartTag returns the first IncludedFileStartTag found in the line // TODO: support multiple tags on the same line ?
func (IncludedFileLine) HasTag ¶ added in v0.3.0
func (l IncludedFileLine) HasTag() bool
HasTag returns true if the line has at least one inclusion tag (start or end), false otherwise
type IncludedFileStartTag ¶ added in v0.3.0
type IncludedFileStartTag struct {
Value string
}
IncludedFileStartTag the type for the `tag::` macro
func NewIncludedFileStartTag ¶ added in v0.3.0
func NewIncludedFileStartTag(tag string) (IncludedFileStartTag, error)
NewIncludedFileStartTag returns a new IncludedFileStartTag
type IndexTerm ¶ added in v0.3.0
type IndexTerm struct {
Term []interface{}
}
IndexTerm a index term, with a single term
func NewIndexTerm ¶ added in v0.3.0
NewIndexTerm returns a new IndexTerm
type InlineImage ¶
type InlineImage struct { Location Location Attributes ElementAttributes }
InlineImage the structure for the inline image macros
func NewInlineImage ¶
func NewInlineImage(path Location, attributes ElementAttributes) (InlineImage, error)
NewInlineImage initializes a new `InlineImage` (similar to ImageBlock, but without attributes)
func (InlineImage) ResolveLocation ¶ added in v0.3.0
func (i InlineImage) ResolveLocation(attrs DocumentAttributesWithOverrides) InlineImage
ResolveLocation resolves the image path using the given document attributes also, updates the `alt` attribute based on the resolved path of the image
type InlineLink ¶
type InlineLink struct { Location Location Attributes ElementAttributes }
InlineLink the structure for the external links
func NewInlineLink ¶
func NewInlineLink(url Location, attrs interface{}) (InlineLink, error)
NewInlineLink initializes a new inline `InlineLink`
type InternalCrossReference ¶ added in v0.3.0
InternalCrossReference the struct for Cross References
func NewInternalCrossReference ¶ added in v0.3.0
func NewInternalCrossReference(id string, label interface{}) (InternalCrossReference, error)
NewInternalCrossReference initializes a new `InternalCrossReference` from the given ID
type LabeledList ¶
type LabeledList struct { Attributes ElementAttributes Items []LabeledListItem }
LabeledList the structure for the Labeled Lists
func NewLabeledList ¶ added in v0.3.0
func NewLabeledList(item LabeledListItem) *LabeledList
NewLabeledList returns a new LabeledList with 1 item The attributes of the given item are moved to the resulting list
func (*LabeledList) AddItem ¶ added in v0.3.0
func (l *LabeledList) AddItem(item LabeledListItem)
AddItem adds the given item
func (*LabeledList) LastItem ¶ added in v0.3.0
func (l *LabeledList) LastItem() ListItem
LastItem returns the last item in this list
type LabeledListItem ¶
type LabeledListItem struct { Term []interface{} Level int Attributes ElementAttributes Elements []interface{} // TODO: rename to `Blocks`? }
LabeledListItem an item in a labeled
func NewLabeledListItem ¶
func NewLabeledListItem(level int, term []interface{}, description interface{}, attributes interface{}) (LabeledListItem, error)
NewLabeledListItem initializes a new LabeledListItem
func (*LabeledListItem) AddElement ¶ added in v0.2.0
func (i *LabeledListItem) AddElement(element interface{})
AddElement add an element to this LabeledListItem
func (LabeledListItem) GetAttributes ¶ added in v0.3.0
func (i LabeledListItem) GetAttributes() ElementAttributes
GetAttributes returns the elements of this UnorderedListItem
type LineBreak ¶
type LineBreak struct{}
LineBreak an explicit line break in a paragraph
func NewLineBreak ¶
NewLineBreak returns a new line break, that's all.
type LineRange ¶ added in v0.3.0
LineRange the range of lines of the child doc to include in the master doc `Start` and `End` are the included limits of the child document - if there's a single line to include, then `End = Start` - if there is all remaining content after a given line (included), then `End = -1`
func NewLineRange ¶ added in v0.3.0
NewLineRange returns a new line range
type LineRanges ¶ added in v0.3.0
type LineRanges []LineRange
LineRanges the ranges of lines of the child doc to include in the master doc
func NewLineRanges ¶ added in v0.3.0
func NewLineRanges(ranges ...interface{}) LineRanges
NewLineRanges returns a slice of line ranges attribute for a file inclusion.
func (LineRanges) Len ¶ added in v0.3.0
func (r LineRanges) Len() int
func (LineRanges) Less ¶ added in v0.3.0
func (r LineRanges) Less(i, j int) bool
func (LineRanges) Match ¶ added in v0.3.0
func (r LineRanges) Match(line int) bool
Match checks if the given line number matches one of the line ranges
func (LineRanges) Swap ¶ added in v0.3.0
func (r LineRanges) Swap(i, j int)
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
type Location ¶ added in v0.3.0
type Location struct {
Elements []interface{}
}
Location a Location contains characters and optionaly, document attributes
func NewLocation ¶ added in v0.3.0
NewLocation return a new location with the given elements
func (*Location) Resolve ¶ added in v0.3.0
func (l *Location) Resolve(attrs DocumentAttributesWithOverrides) Location
Resolve resolves the Location by replacing all document attribute substitutions with their associated values, or their corresponding raw text if no attribute matched returns `true` if some document attribute substitution occurred
type Metadata ¶ added in v0.3.0
type Metadata struct { Title string LastUpdated string TableOfContents TableOfContents Authors []DocumentAuthor Revision DocumentRevision }
Metadata the document metadata returned after the rendering
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 NewOrderedList ¶ added in v0.3.0
func NewOrderedList(item *OrderedListItem) *OrderedList
NewOrderedList initializes a new ordered list with the given item
func (*OrderedList) AddItem ¶ added in v0.3.0
func (l *OrderedList) AddItem(item OrderedListItem)
AddItem adds the given item
func (*OrderedList) LastItem ¶ added in v0.3.0
func (l *OrderedList) LastItem() ListItem
LastItem returns the last item in this list
type OrderedListItem ¶
type OrderedListItem struct { Attributes ElementAttributes Level int NumberingStyle NumberingStyle Elements []interface{} // TODO: rename to `Blocks`? }
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) AddElement ¶ added in v0.2.0
func (i *OrderedListItem) AddElement(element interface{})
AddElement add an element to this OrderedListItem
func (OrderedListItem) GetAttributes ¶ added in v0.3.0
func (i OrderedListItem) GetAttributes() ElementAttributes
GetAttributes returns the elements of this UnorderedListItem
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 [][]interface{} }
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 ¶
NewParagraph initializes a new `Paragraph`
func (Paragraph) AddAttributes ¶
func (p Paragraph) AddAttributes(attributes ElementAttributes)
AddAttributes adds all given attributes to the current set of attribute of the element
func (Paragraph) ReplaceFootnotes ¶ added in v0.4.0
ReplaceFootnotes replaces the footnotes in the paragraph lines with footnote references. The footnotes are stored in the given 'notes' param
type Passthrough ¶
type Passthrough struct { Kind PassthroughKind Elements []interface{} }
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 (Preamble) HasContent ¶ added in v0.3.0
HasContent returns `true` if this Preamble has at least one element which is neither a BlankLine nor a DocumentAttributeDeclaration
type QuotedText ¶
type QuotedText struct { Kind QuotedTextKind Elements []interface{} }
QuotedText the structure for quoted text
func NewQuotedText ¶
func NewQuotedText(kind QuotedTextKind, elements ...interface{}) (QuotedText, error)
NewQuotedText initializes a new `QuotedText` from the given kind and content
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 Attributes ElementAttributes Title []interface{} Elements []interface{} }
Section the structure for a section
func NewDocumentHeader ¶
func NewDocumentHeader(title []interface{}, authors interface{}, revision interface{}) (Section, error)
NewDocumentHeader initializes a new Section with level 0 which can have authors and a revision, among other attributes
func NewSection ¶
func NewSection(level int, title []interface{}, ids []interface{}, attributes interface{}) (Section, error)
NewSection initializes a new `Section` from the given section title and elements
func (*Section) AddElement ¶ added in v0.3.0
func (s *Section) AddElement(e interface{})
AddElement adds the given child element to this section
func (Section) ReplaceFootnotes ¶ added in v0.4.0
ReplaceFootnotes replaces the footnotes in the section title with footnote references. The footnotes are stored in the given 'notes' param
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, error)
NewStringElement initializes a new `StringElement` from the given content
func (StringElement) String ¶ added in v0.3.0
func (s StringElement) String() string
String return the content of this StringElement
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
type TableLine ¶
type TableLine struct {
Cells [][]interface{}
}
TableLine a table line is made of columns, each column being a group of []interface{} (to support quoted text, etc.)
func NewTableLine ¶
NewTableLine initializes a new TableLine with the given columns
type TableOfContents ¶ added in v0.3.0
type TableOfContents struct {
Sections []ToCSection
}
TableOfContents the table of contents
type TableOfContentsPlaceHolder ¶ added in v0.3.0
type TableOfContentsPlaceHolder struct { }
TableOfContentsPlaceHolder a place holder for Table of Contents, so the renderer knows when to render it.
type TagRange ¶ added in v0.3.0
TagRange the range to include or exclude from the file inclusion. The range is excluded if it is prefixed with '!' Also, '*' and '**' have a special meaning: - '*' means that all tag ranges are included (except the lines having the start and end ranges) - '**' means that all content is included, regardless of whether it is in a tag or not (except the lines having the start and end ranges)
type TagRanges ¶ added in v0.3.0
type TagRanges []TagRange
TagRanges the ranges of tags of the child doc to include in the master doc
func NewTagRanges ¶ added in v0.3.0
NewTagRanges returns a slice of tag ranges attribute for a file inclusion.
type ToCSection ¶ added in v0.3.0
type ToCSection struct { ID string Level int Title string // the title as it was rendered in HTML Children []ToCSection }
ToCSection a section in the table of contents
type UnorderedList ¶
type UnorderedList struct { Attributes ElementAttributes Items []UnorderedListItem }
UnorderedList the structure for the Unordered Lists
func NewUnorderedList ¶ added in v0.3.0
func NewUnorderedList(item *UnorderedListItem) *UnorderedList
NewUnorderedList returns a new UnorderedList with 1 item The attributes of the given item are moved to the resulting list
func (*UnorderedList) AddItem ¶ added in v0.3.0
func (l *UnorderedList) AddItem(item UnorderedListItem)
AddItem adds the given item
func (*UnorderedList) LastItem ¶ added in v0.3.0
func (l *UnorderedList) LastItem() ListItem
LastItem returns the last item in this list
type UnorderedListItem ¶
type UnorderedListItem struct { Level int BulletStyle BulletStyle CheckStyle UnorderedListItemCheckStyle Attributes ElementAttributes Elements []interface{} // TODO: rename to `Blocks`? }
UnorderedListItem the structure for the unordered list items
func NewUnorderedListItem ¶
func NewUnorderedListItem(prefix UnorderedListItemPrefix, checkstyle interface{}, elements []interface{}, attributes interface{}) (UnorderedListItem, error)
NewUnorderedListItem initializes a new `UnorderedListItem` from the given content
func (*UnorderedListItem) AddElement ¶ added in v0.2.0
func (i *UnorderedListItem) AddElement(element interface{})
AddElement add an element to this UnorderedListItem
func (UnorderedListItem) GetAttributes ¶ added in v0.3.0
func (i UnorderedListItem) GetAttributes() ElementAttributes
GetAttributes returns the elements of this UnorderedListItem
type UnorderedListItemCheckStyle ¶ added in v0.2.0
type UnorderedListItemCheckStyle string
UnorderedListItemCheckStyle the check style that applies on an unordered list item
const ( // Checked when the unordered list item is checked Checked UnorderedListItemCheckStyle = "checked" // Unchecked when the unordered list item is not checked Unchecked UnorderedListItemCheckStyle = "unchecked" // NoCheck when the unodered list item has no specific check annotation NoCheck UnorderedListItemCheckStyle = "nocheck" )
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 UserMacro ¶ added in v0.3.0
type UserMacro struct { Kind MacroKind Name string Value string Attributes ElementAttributes RawText string }
UserMacro the structure for User Macro
func NewInlineUserMacro ¶ added in v0.3.0
func NewInlineUserMacro(name, value string, attrs ElementAttributes, raw string) (UserMacro, error)
NewInlineUserMacro returns an UserMacro
func NewUserMacroBlock ¶ added in v0.3.0
func NewUserMacroBlock(name string, value string, attrs ElementAttributes, raw string) (UserMacro, error)
NewUserMacroBlock returns an UserMacro