Documentation
¶
Overview ¶
Package pandoc provides Go types and functions for working with Pandoc's JSON AST format. It supports parsing Pandoc JSON output and provides structured access to document elements.
Index ¶
- Constants
- type Attr
- type Block
- type BlockList
- type BlockQuote
- type BulletList
- type Cell
- type Cite
- type Code
- type CodeBlock
- type ColSpec
- type DefinitionItem
- type DefinitionList
- type Div
- type Document
- type Figure
- type Formatted
- type Header
- type HorizontalRule
- type Image
- type Inline
- type InlineFmt
- type InlineList
- type KeyVal
- type LineBlock
- type LineBreak
- type Link
- type Math
- type Note
- type Null
- type OrderedList
- type Para
- type Plain
- type Quoted
- type RawBlock
- type RawInline
- type Row
- type SoftBreak
- type Space
- type Span
- type Str
- type TC
- type Table
- type TableBody
- type TableHeadOrFoot
- type Target
Constants ¶
const ( Emph = InlineFmt(iota) // Emphasis (italic) Underline // Underlined text Strong // Strong emphasis (bold) Strikeout // Strikethrough text Superscript // Superscript text Subscript // Subscript text SmallCaps // Small capitals )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Attr ¶
type Attr struct {
Identifier string // Element identifier for cross-referencing
Classes []string // CSS-style class names
KeyVals []*KeyVal // Additional key-value attributes
}
Attr represents Pandoc attributes with an identifier, classes, and key-value pairs. This is used for blocks and inline elements that support attributes.
type Block ¶
type Block interface {
}
Block is the interface implemented by all Pandoc block-level elements. Block elements include paragraphs, headers, lists, tables, and other structural components of a document.
type BlockQuote ¶
type BlockQuote struct {
Blocks BlockList
}
BlockQuote represents a block quotation.
type BulletList ¶
type BulletList struct {
Items []BlockList
}
type Cite ¶
type Cite struct {
Id string
Prefix InlineList
Suffix InlineList
Mode string // AuthorInText, SuppressAuthor, NormalCitation
NoteNum int
Hash int
Content InlineList
}
type CodeBlock ¶
type CodeBlock struct {
Attr Attr // Attributes including language class
Text string // Code content
}
CodeBlock represents a code block with optional attributes and language specification.
type DefinitionItem ¶
type DefinitionItem struct {
Term InlineList
Definitions []BlockList
}
type DefinitionList ¶
type DefinitionList struct {
Items []*DefinitionItem
}
type Document ¶
type Document struct {
PandocApiVersion json.RawMessage `json:"pandoc-api-version"` // Pandoc API version
Meta map[string]interface{} `json:"meta"` // Document metadata
Blocks []interface{} `json:"blocks"` // Top-level blocks
}
Document represents a Pandoc JSON document with API version, metadata, and blocks.
func NewDocument ¶
NewDocument parses Pandoc JSON output into a Document structure. The buf parameter should contain JSON output from `pandoc -t json`.
type Figure ¶ added in v0.1.0
type Figure struct {
Attr Attr
ShortCaption InlineList
Caption BlockList
Blocks BlockList
}
type Formatted ¶
type Formatted struct {
Fmt InlineFmt
Content InlineList
}
type Header ¶
type Header struct {
Level int // Heading level (1-6)
Attr Attr // Heading attributes
Inlines InlineList // Heading text
}
Header represents a heading with level, attributes, and inline content.
type HorizontalRule ¶
type HorizontalRule struct {
}
HorizontalRule represents a horizontal rule (thematic break).
type Image ¶
type Image struct {
Attr Attr
Content InlineList
Target Target
}
type Inline ¶
type Inline interface {
}
Inline is the interface implemented by all Pandoc inline elements. Inline elements include text, formatting, links, images, and other content that appears within block elements.
type InlineFmt ¶
type InlineFmt int
InlineFmt represents inline formatting types (emphasis, strong, etc.).
type LineBlock ¶
type LineBlock struct {
Lines []InlineList
}
LineBlock represents a block of lines where line breaks are preserved.
type Link ¶
type Link struct {
Attr Attr
Content InlineList
Target Target
}
type OrderedList ¶
OrderedList represents a numbered list.
type Plain ¶
type Plain struct {
Inlines InlineList
}
Plain represents a plain text block without paragraph formatting.
type Quoted ¶
type Quoted struct {
QuoteType string // SingleQuote or DoubleQuote
Content InlineList
}
type Span ¶
type Span struct {
Attr Attr
Content InlineList
}
type TC ¶
type TC struct {
T string `json:"t"` // Type tag
C interface{} `json:"c"` // Content
}
TC represents a tagged container with type (T) and content (C) fields. This is Pandoc's standard format for encoding AST elements in JSON.
type Table ¶
type Table struct {
Attr Attr // Table attributes
ShortCaption InlineList // Short caption for list of tables
Caption BlockList // Full caption blocks
ColSpecs []*ColSpec // Column specifications
Head TableHeadOrFoot // Table header
Bodies []*TableBody // Table bodies
Foot TableHeadOrFoot // Table footer
}
Table represents a table with caption, column specifications, header, body, and footer.
type TableHeadOrFoot ¶
TableHeadOrFoot represents a table header or footer section.