org

package
v1.11.14 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package org is an Org mode syntax processor.

It parses plain text into an AST and can export it as HTML or pretty printed Org mode syntax. Further export formats can be defined using the Writer interface.

You probably want to start with something like this:

input := strings.NewReader("Your Org mode input")
html, err := org.New().Parse(input, "./").Write(org.NewHTMLWriter())
if err != nil {
    log.Fatalf("Something went wrong: %s", err)
}
log.Print(html)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNewLineChar

func IsNewLineChar(r rune) bool

func ParseRanges

func ParseRanges(s string) [][2]int

Parse ranges like this: "3-5" -> [[3, 5]] "3 8-10" -> [[3, 3], [8, 10]] "3 5 6" -> [[3, 3], [5, 5], [6, 6]]

This is Hugo's hlLinesToRanges with "startLine" removed and errors ignored.

func PrintNodeTree added in v1.11.4

func PrintNodeTree(nodes []Node, indent string) string

PrintNodeTree returns a string representation of an org.Node hierarchy as a tree showing types, positions, and string representations.

func String

func String(nodes ...Node) string

String returns the pretty printed Org mode string for the given nodes (see OrgWriter).

func WriteNodes

func WriteNodes(w Writer, nodes ...Node)

Types

type Block

type Block struct {
	Name       string
	Parameters []string
	Children   []Node
	Result     Node
	Pos        Position
}

func (Block) Copy added in v1.11.3

func (n Block) Copy() Node

func (Block) ParameterMap

func (b Block) ParameterMap() map[string]string

func (Block) Position added in v1.11.3

func (n Block) Position() Position

func (Block) Range added in v1.11.3

func (n Block) Range(f func(Node) bool)

func (Block) String

func (n Block) String() string

type Column

type Column struct {
	Children []Node
	*ColumnInfo
	Pos Position
}

type ColumnInfo

type ColumnInfo struct {
	Align      string
	Len        int
	DisplayLen int
	Pos        Position
}

type Comment

type Comment struct {
	Content string
	Pos     Position
}

func (Comment) Copy added in v1.11.3

func (n Comment) Copy() Node

func (Comment) Position added in v1.11.3

func (n Comment) Position() Position

func (Comment) Range added in v1.11.3

func (n Comment) Range(f func(Node) bool)

func (Comment) String

func (n Comment) String() string

type Configuration

type Configuration struct {
	MaxEmphasisNewLines int                                   // Maximum number of newlines inside an emphasis. See org-emphasis-regexp-components newline.
	AutoLink            bool                                  // Try to convert text passages that look like hyperlinks into hyperlinks.
	DefaultSettings     map[string]string                     // Default values for settings that are overriden by setting the same key in BufferSettings.
	Log                 *log.Logger                           // Log is used to print warnings during parsing.
	ReadFile            func(filename string) ([]byte, error) // ReadFile is used to read e.g. #+INCLUDE files.
	ResolveLink         func(protocol string, description []Node, link string) Node
}

func New

func New() *Configuration

New returns a new Configuration with (hopefully) sane defaults.

func (*Configuration) Parse

func (c *Configuration) Parse(input io.Reader, path string) (d *Document)

Parse parses the input into an AST (and some other helpful fields like Outline). To allow method chaining, errors are stored in document.Error rather than being returned.

func (*Configuration) Silent

func (c *Configuration) Silent() *Configuration

Silent disables all logging of warnings during parsing.

type DescriptiveListItem

type DescriptiveListItem struct {
	Bullet  string
	Status  string
	Term    []Node
	Details []Node
	Pos     Position
}

func (DescriptiveListItem) Copy added in v1.11.3

func (n DescriptiveListItem) Copy() Node

func (DescriptiveListItem) Position added in v1.11.3

func (n DescriptiveListItem) Position() Position

func (DescriptiveListItem) Range added in v1.11.3

func (n DescriptiveListItem) Range(f func(Node) bool)

func (DescriptiveListItem) String

func (n DescriptiveListItem) String() string

type Document

type Document struct {
	*Configuration
	Path string // Path of the file containing the parse input - used to resolve relative paths during parsing (e.g. INCLUDE).

	Macros         map[string]string
	Links          map[string]string
	Nodes          []Node
	NamedNodes     map[string]Node
	Outline        Outline           // Outline is a Table Of Contents for the document and contains all sections (headline + content).
	BufferSettings map[string]string // Settings contains all settings that were parsed from keywords.
	Errors         []*ParseError     // Structured parsing errors with position information
	FatalError     *ParseError       // Fatal error that prevented successful parsing
	Pos            Position          // Position tracks the location of this document in the source
	// contains filtered or unexported fields
}

Document contains the parsing results and a pointer to the Configuration.

func (*Document) AddError added in v1.11.1

func (d *Document) AddError(typ ErrorType, message string, pos Position, tok token, cause error)

AddError adds a new parsing error to the document with detailed position info. This is the preferred method for reporting errors during parsing.

func (*Document) AddFatalError added in v1.11.3

func (d *Document) AddFatalError(typ ErrorType, message string, pos Position, tok token, cause error)

AddFatalError sets a fatal error that prevents successful parsing. This is used for unrecoverable errors where the parser cannot continue.

func (*Document) ErrorCount added in v1.11.1

func (d *Document) ErrorCount() int

ErrorCount returns the number of parsing errors in the document.

func (*Document) Get

func (d *Document) Get(key string) string

Get returns the value for key in BufferSettings or DefaultSettings if key does not exist in the former

func (*Document) GetErrorByType added in v1.11.1

func (d *Document) GetErrorByType(typ ErrorType) []*ParseError

GetErrorByType returns all errors of the specified type.

func (*Document) GetOption

func (d *Document) GetOption(key string) string

GetOption returns the value associated to the export option key Currently supported options: - < (export timestamps) - e (export org entities) - f (export footnotes) - title (export title) - toc (export table of content. an int limits the included org headline lvl) - todo (export headline todo status) - pri (export headline priority) - tags (export headline tags) - ealb (non-standard) (export with east asian line breaks / ignore line breaks between multi-byte characters) see https://orgmode.org/manual/Export-Settings.html for more information

func (*Document) HasErrors added in v1.11.1

func (d *Document) HasErrors() bool

HasErrors returns true if the document contains any parsing errors.

func (*Document) HasFatalError added in v1.11.3

func (d *Document) HasFatalError() bool

HasFatalError returns true if the document has a fatal error that prevented successful parsing.

func (*Document) Write

func (d *Document) Write(w Writer) (out string, err error)

Write is called after with an instance of the Writer interface to export a parsed Document into another format.

func (*Document) WriteErrors added in v1.11.1

func (d *Document) WriteErrors(w io.Writer) error

WriteErrors writes all document errors to the provided writer, one per line.

type Drawer

type Drawer struct {
	Name     string
	Children []Node
	Pos      Position
}

func (Drawer) Copy added in v1.11.3

func (n Drawer) Copy() Node

func (Drawer) Position added in v1.11.3

func (n Drawer) Position() Position

func (Drawer) Range added in v1.11.3

func (n Drawer) Range(f func(Node) bool)

func (Drawer) String

func (n Drawer) String() string

type Emphasis

type Emphasis struct {
	Kind    string
	Content []Node
	Pos     Position
}

func (Emphasis) Copy added in v1.11.3

func (n Emphasis) Copy() Node

func (Emphasis) Position added in v1.11.3

func (n Emphasis) Position() Position

func (Emphasis) Range added in v1.11.3

func (n Emphasis) Range(f func(Node) bool)

func (Emphasis) String

func (n Emphasis) String() string

type ErrorType added in v1.11.1

type ErrorType string

ErrorType represents the kind of error that occurred.

const (
	ErrorTypeInvalidSyntax    ErrorType = "invalid_syntax"
	ErrorTypeUnexpectedToken  ErrorType = "unexpected_token"
	ErrorTypeInvalidStructure ErrorType = "invalid_structure"
	ErrorTypeDuplicateNode    ErrorType = "duplicate_node"
	ErrorTypeMissingNode      ErrorType = "missing_node"
	ErrorTypeValidation       ErrorType = "validation_error"
	ErrorTypeTokenization     ErrorType = "tokenization_error"
	ErrorTypeIO               ErrorType = "io_error"
)

type Example

type Example struct {
	Children []Node
	Pos      Position
}

func (Example) Copy added in v1.11.3

func (n Example) Copy() Node

func (Example) Position added in v1.11.3

func (n Example) Position() Position

func (Example) Range added in v1.11.3

func (n Example) Range(f func(Node) bool)

func (Example) String

func (n Example) String() string

type ExplicitLineBreak

type ExplicitLineBreak struct {
	Pos Position
}

func (ExplicitLineBreak) Copy added in v1.11.3

func (n ExplicitLineBreak) Copy() Node

func (ExplicitLineBreak) Position added in v1.11.3

func (n ExplicitLineBreak) Position() Position

func (ExplicitLineBreak) Range added in v1.11.3

func (n ExplicitLineBreak) Range(f func(Node) bool)

func (ExplicitLineBreak) String

func (n ExplicitLineBreak) String() string

type FootnoteDefinition

type FootnoteDefinition struct {
	Name     string
	Children []Node
	Inline   bool
	Pos      Position
}

func (FootnoteDefinition) Copy added in v1.11.3

func (n FootnoteDefinition) Copy() Node

func (FootnoteDefinition) Position added in v1.11.3

func (n FootnoteDefinition) Position() Position

func (FootnoteDefinition) Range added in v1.11.3

func (n FootnoteDefinition) Range(f func(Node) bool)

func (FootnoteDefinition) String

func (n FootnoteDefinition) String() string
type FootnoteLink struct {
	Name       string
	Definition *FootnoteDefinition
	Pos        Position
}

func (FootnoteLink) Copy added in v1.11.3

func (n FootnoteLink) Copy() Node

func (FootnoteLink) Position added in v1.11.3

func (n FootnoteLink) Position() Position

func (FootnoteLink) Range added in v1.11.3

func (n FootnoteLink) Range(f func(Node) bool)

func (FootnoteLink) String

func (n FootnoteLink) String() string

type HTMLWriter

type HTMLWriter struct {
	ExtendingWriter     Writer
	HighlightCodeBlock  func(source, lang string, inline bool, params map[string]string) string
	PrettyRelativeLinks bool
	// TopLevelHLevel determines what HTML heading to use for a
	// level-1 Org headline, and by extension further headings.
	//
	// For example, a value of 1 means a top-level Org headline will be
	// rendered as an <h1> element, a level-2 Org headline will be
	// rendered as an <h2> element, and so on.
	//
	// A value of 2 (default) means a top-level Org headline will be
	// rendered as an <h2> element, a level-2 Org headline will be
	// rendered as an <h3> element, and so on.
	//
	// This setting and its default behavior match Org's
	// :html-toplevel-hlevel export property and the associated
	// org-html-toplevel-hlevel variable.
	TopLevelHLevel int

	strings.Builder
	// contains filtered or unexported fields
}

HTMLWriter exports an org document into a html document.

func NewHTMLWriter

func NewHTMLWriter() *HTMLWriter

func (*HTMLWriter) After

func (w *HTMLWriter) After(d *Document)

func (*HTMLWriter) Before

func (w *HTMLWriter) Before(d *Document)

func (*HTMLWriter) WriteBlock

func (w *HTMLWriter) WriteBlock(b Block)

func (*HTMLWriter) WriteComment

func (w *HTMLWriter) WriteComment(Comment)

func (*HTMLWriter) WriteDescriptiveListItem

func (w *HTMLWriter) WriteDescriptiveListItem(di DescriptiveListItem)

func (*HTMLWriter) WriteDrawer

func (w *HTMLWriter) WriteDrawer(d Drawer)

func (*HTMLWriter) WriteEmphasis

func (w *HTMLWriter) WriteEmphasis(e Emphasis)

func (*HTMLWriter) WriteExample

func (w *HTMLWriter) WriteExample(e Example)

func (*HTMLWriter) WriteExplicitLineBreak

func (w *HTMLWriter) WriteExplicitLineBreak(l ExplicitLineBreak)

func (*HTMLWriter) WriteFootnoteDefinition

func (w *HTMLWriter) WriteFootnoteDefinition(f FootnoteDefinition)
func (w *HTMLWriter) WriteFootnoteLink(l FootnoteLink)

func (*HTMLWriter) WriteFootnotes

func (w *HTMLWriter) WriteFootnotes(d *Document)

func (*HTMLWriter) WriteHeadline

func (w *HTMLWriter) WriteHeadline(h Headline)

func (*HTMLWriter) WriteHorizontalRule

func (w *HTMLWriter) WriteHorizontalRule(h HorizontalRule)

func (*HTMLWriter) WriteInclude

func (w *HTMLWriter) WriteInclude(i Include)

func (*HTMLWriter) WriteInlineBlock

func (w *HTMLWriter) WriteInlineBlock(b InlineBlock)

func (*HTMLWriter) WriteKeyword

func (w *HTMLWriter) WriteKeyword(k Keyword)

func (*HTMLWriter) WriteLatexBlock

func (w *HTMLWriter) WriteLatexBlock(b LatexBlock)

func (*HTMLWriter) WriteLatexFragment

func (w *HTMLWriter) WriteLatexFragment(l LatexFragment)

func (*HTMLWriter) WriteLineBreak

func (w *HTMLWriter) WriteLineBreak(l LineBreak)

func (*HTMLWriter) WriteList

func (w *HTMLWriter) WriteList(l List)

func (*HTMLWriter) WriteListItem

func (w *HTMLWriter) WriteListItem(li ListItem)

func (*HTMLWriter) WriteMacro

func (w *HTMLWriter) WriteMacro(m Macro)

func (*HTMLWriter) WriteNodeWithMeta

func (w *HTMLWriter) WriteNodeWithMeta(n NodeWithMeta)

func (*HTMLWriter) WriteNodeWithName

func (w *HTMLWriter) WriteNodeWithName(n NodeWithName)

func (*HTMLWriter) WriteNodesAsString

func (w *HTMLWriter) WriteNodesAsString(nodes ...Node) string

func (*HTMLWriter) WriteOutline

func (w *HTMLWriter) WriteOutline(d *Document, maxLvl int)

func (*HTMLWriter) WriteParagraph

func (w *HTMLWriter) WriteParagraph(p Paragraph)

func (*HTMLWriter) WritePropertyDrawer

func (w *HTMLWriter) WritePropertyDrawer(PropertyDrawer)
func (w *HTMLWriter) WriteRegularLink(l RegularLink)

func (*HTMLWriter) WriteResult

func (w *HTMLWriter) WriteResult(r Result)

func (*HTMLWriter) WriteStatisticToken

func (w *HTMLWriter) WriteStatisticToken(s StatisticToken)

func (*HTMLWriter) WriteTable

func (w *HTMLWriter) WriteTable(t Table)

func (*HTMLWriter) WriteText

func (w *HTMLWriter) WriteText(t Text)

func (*HTMLWriter) WriteTimestamp

func (w *HTMLWriter) WriteTimestamp(t Timestamp)

func (*HTMLWriter) WriterWithExtensions

func (w *HTMLWriter) WriterWithExtensions() Writer

type Headline

type Headline struct {
	Index      int
	Lvl        int
	Status     string
	IsComment  bool
	Priority   string
	Properties *PropertyDrawer
	Title      []Node
	Tags       []string
	Children   []Node
	Pos        Position
}

func (Headline) Copy added in v1.11.3

func (n Headline) Copy() Node

func (Headline) ID

func (h Headline) ID() string

func (Headline) IsExcluded

func (h Headline) IsExcluded(d *Document) bool

func (Headline) Position added in v1.11.3

func (n Headline) Position() Position

func (Headline) Range added in v1.11.3

func (n Headline) Range(f func(Node) bool)

func (Headline) String

func (n Headline) String() string

type HorizontalRule

type HorizontalRule struct {
	Pos Position
}

func (HorizontalRule) Copy added in v1.11.3

func (n HorizontalRule) Copy() Node

func (HorizontalRule) Position added in v1.11.3

func (n HorizontalRule) Position() Position

func (HorizontalRule) Range added in v1.11.3

func (n HorizontalRule) Range(f func(Node) bool)

func (HorizontalRule) String

func (n HorizontalRule) String() string

type Include

type Include struct {
	Keyword
	Resolve func() Node
	Pos     Position
}

func (Include) Copy added in v1.11.3

func (n Include) Copy() Node

func (Include) Position added in v1.11.3

func (n Include) Position() Position

func (Include) Range added in v1.11.3

func (n Include) Range(f func(Node) bool)

func (Include) String

func (n Include) String() string

type InlineBlock

type InlineBlock struct {
	Name       string
	Parameters []string
	Children   []Node
	Pos        Position
}

func (InlineBlock) Copy added in v1.11.3

func (n InlineBlock) Copy() Node

func (InlineBlock) Position added in v1.11.3

func (n InlineBlock) Position() Position

func (InlineBlock) Range added in v1.11.3

func (n InlineBlock) Range(f func(Node) bool)

func (InlineBlock) String

func (n InlineBlock) String() string

type Keyword

type Keyword struct {
	Key   string
	Value string
	Pos   Position
}

func (Keyword) Copy added in v1.11.3

func (n Keyword) Copy() Node

func (Keyword) Position added in v1.11.3

func (n Keyword) Position() Position

func (Keyword) Range added in v1.11.3

func (n Keyword) Range(f func(Node) bool)

func (Keyword) String

func (n Keyword) String() string

type LatexBlock

type LatexBlock struct {
	Content []Node
	Pos     Position
}

func (LatexBlock) Copy added in v1.11.3

func (n LatexBlock) Copy() Node

func (LatexBlock) Position added in v1.11.3

func (n LatexBlock) Position() Position

func (LatexBlock) Range added in v1.11.3

func (n LatexBlock) Range(f func(Node) bool)

func (LatexBlock) String

func (n LatexBlock) String() string

type LatexFragment

type LatexFragment struct {
	OpeningPair string
	ClosingPair string
	Content     []Node
	Pos         Position
}

func (LatexFragment) Copy added in v1.11.3

func (n LatexFragment) Copy() Node

func (LatexFragment) Position added in v1.11.3

func (n LatexFragment) Position() Position

func (LatexFragment) Range added in v1.11.3

func (n LatexFragment) Range(f func(Node) bool)

func (LatexFragment) String

func (n LatexFragment) String() string

type LineBreak

type LineBreak struct {
	Count                      int
	BetweenMultibyteCharacters bool
	Pos                        Position
}

func (LineBreak) Copy added in v1.11.3

func (n LineBreak) Copy() Node

func (LineBreak) Position added in v1.11.3

func (n LineBreak) Position() Position

func (LineBreak) Range added in v1.11.3

func (n LineBreak) Range(f func(Node) bool)

func (LineBreak) String

func (n LineBreak) String() string

type List

type List struct {
	// Kind indicates the type of list (unordered, ordered, or descriptive)
	Kind ListKind
	// Items contains the individual list items that belong to this list
	Items []Node
	// Pos tracks the source document position where this list begins
	Pos Position
}

List represents a collection of ListItem or DescriptiveListItem nodes, forming an ordered, unordered, or descriptive list in an org-mode document.

func (List) Copy added in v1.11.3

func (n List) Copy() Node

func (List) Position added in v1.11.3

func (n List) Position() Position

func (List) Range added in v1.11.3

func (n List) Range(f func(Node) bool)

func (List) String

func (n List) String() string

type ListItem

type ListItem struct {
	// Bullet is the literal list marker character(s) from source:
	//   "-" "*" "+" for unordered; "1.", "a)", "A)" for ordered
	Bullet string
	// Status is a single character indicating completion state:
	//   " " (incomplete), "X" (done), or "-" (partial)
	// Appears as "[ ]", "[X]", or "[-]" in source text
	Status string
	// Value is for ordered lists only: overrides automatic numbering with [@num]
	// Allows explicit numbering like "[@5]" to force a specific number
	Value string
	// Children contains the actual content nodes after the marker/status/value prefixes
	// Includes text, nested lists, code blocks, or other Org elements
	Children []Node
	// Pos tracks the source document position where this list item begins
	Pos Position
}

ListItem represents a single list item within an ordered or unordered list. It captures the bullet marker, optional status checkbox, value override, and child content.

func (ListItem) Copy added in v1.11.3

func (n ListItem) Copy() Node

func (ListItem) Position added in v1.11.3

func (n ListItem) Position() Position

func (ListItem) Range added in v1.11.3

func (n ListItem) Range(f func(Node) bool)

func (ListItem) String

func (n ListItem) String() string

type ListKind added in v1.11.3

type ListKind int
const (
	UnorderedList ListKind = iota
	OrderedList
	DescriptiveList
)

func (ListKind) String added in v1.11.3

func (k ListKind) String() string

type Macro

type Macro struct {
	Name       string
	Parameters []string
	Pos        Position
}

func (Macro) Copy added in v1.11.3

func (n Macro) Copy() Node

func (Macro) Position added in v1.11.3

func (n Macro) Position() Position

func (Macro) Range added in v1.11.3

func (n Macro) Range(f func(Node) bool)

func (Macro) String

func (n Macro) String() string

type Metadata

type Metadata struct {
	Caption        [][]Node
	HTMLAttributes [][]string
	Pos            Position
}

type Node

type Node interface {
	String() string        // String returns the pretty printed Org mode string for the node (see OrgWriter).
	Copy() Node            // Copy returns a deep copy of the node.
	Range(func(Node) bool) // Range iterates over all children of the node. Stops if the function returns false.
	Position() Position    // Position returns the position of the node in the source text.
}

Node represents a parsed node of the document.

func CopyNodes added in v1.11.3

func CopyNodes(nodes []Node) []Node

CopyNodes returns a deep copy of a slice of nodes.

type NodeWithMeta

type NodeWithMeta struct {
	Node Node
	Meta Metadata
	Pos  Position
}

func (NodeWithMeta) Copy added in v1.11.3

func (n NodeWithMeta) Copy() Node

func (NodeWithMeta) Position added in v1.11.3

func (n NodeWithMeta) Position() Position

func (NodeWithMeta) Range added in v1.11.3

func (n NodeWithMeta) Range(f func(Node) bool)

func (NodeWithMeta) String

func (n NodeWithMeta) String() string

type NodeWithName

type NodeWithName struct {
	Name string
	Node Node
	Pos  Position
}

func (NodeWithName) Copy added in v1.11.3

func (n NodeWithName) Copy() Node

func (NodeWithName) Position added in v1.11.3

func (n NodeWithName) Position() Position

func (NodeWithName) Range added in v1.11.3

func (n NodeWithName) Range(f func(Node) bool)

func (NodeWithName) String

func (n NodeWithName) String() string

type OrgWriter

type OrgWriter struct {
	ExtendingWriter Writer
	TagsColumn      int

	strings.Builder
	// contains filtered or unexported fields
}

OrgWriter export an org document into pretty printed org document.

func NewOrgWriter

func NewOrgWriter() *OrgWriter

func (*OrgWriter) After

func (w *OrgWriter) After(d *Document)

func (*OrgWriter) Before

func (w *OrgWriter) Before(d *Document)

func (*OrgWriter) WriteBlock

func (w *OrgWriter) WriteBlock(b Block)

func (*OrgWriter) WriteComment

func (w *OrgWriter) WriteComment(c Comment)

func (*OrgWriter) WriteDescriptiveListItem

func (w *OrgWriter) WriteDescriptiveListItem(di DescriptiveListItem)

func (*OrgWriter) WriteDrawer

func (w *OrgWriter) WriteDrawer(d Drawer)

func (*OrgWriter) WriteEmphasis

func (w *OrgWriter) WriteEmphasis(e Emphasis)

func (*OrgWriter) WriteExample

func (w *OrgWriter) WriteExample(e Example)

func (*OrgWriter) WriteExplicitLineBreak

func (w *OrgWriter) WriteExplicitLineBreak(l ExplicitLineBreak)

func (*OrgWriter) WriteFootnoteDefinition

func (w *OrgWriter) WriteFootnoteDefinition(f FootnoteDefinition)
func (w *OrgWriter) WriteFootnoteLink(l FootnoteLink)

func (*OrgWriter) WriteHeadline

func (w *OrgWriter) WriteHeadline(h Headline)

func (*OrgWriter) WriteHorizontalRule

func (w *OrgWriter) WriteHorizontalRule(hr HorizontalRule)

func (*OrgWriter) WriteInclude

func (w *OrgWriter) WriteInclude(i Include)

func (*OrgWriter) WriteInlineBlock

func (w *OrgWriter) WriteInlineBlock(b InlineBlock)

func (*OrgWriter) WriteKeyword

func (w *OrgWriter) WriteKeyword(k Keyword)

func (*OrgWriter) WriteLatexBlock

func (w *OrgWriter) WriteLatexBlock(b LatexBlock)

func (*OrgWriter) WriteLatexFragment

func (w *OrgWriter) WriteLatexFragment(l LatexFragment)

func (*OrgWriter) WriteLineBreak

func (w *OrgWriter) WriteLineBreak(l LineBreak)

func (*OrgWriter) WriteList

func (w *OrgWriter) WriteList(l List)

func (*OrgWriter) WriteListItem

func (w *OrgWriter) WriteListItem(li ListItem)

func (*OrgWriter) WriteMacro

func (w *OrgWriter) WriteMacro(m Macro)

func (*OrgWriter) WriteNodeWithMeta

func (w *OrgWriter) WriteNodeWithMeta(n NodeWithMeta)

func (*OrgWriter) WriteNodeWithName

func (w *OrgWriter) WriteNodeWithName(n NodeWithName)

func (*OrgWriter) WriteNodesAsString

func (w *OrgWriter) WriteNodesAsString(nodes ...Node) string

func (*OrgWriter) WriteParagraph

func (w *OrgWriter) WriteParagraph(p Paragraph)

func (*OrgWriter) WritePropertyDrawer

func (w *OrgWriter) WritePropertyDrawer(d PropertyDrawer)
func (w *OrgWriter) WriteRegularLink(l RegularLink)

func (*OrgWriter) WriteResult

func (w *OrgWriter) WriteResult(r Result)

func (*OrgWriter) WriteStatisticToken

func (w *OrgWriter) WriteStatisticToken(s StatisticToken)

func (*OrgWriter) WriteTable

func (w *OrgWriter) WriteTable(t Table)

func (*OrgWriter) WriteText

func (w *OrgWriter) WriteText(t Text)

func (*OrgWriter) WriteTimestamp

func (w *OrgWriter) WriteTimestamp(t Timestamp)

func (*OrgWriter) WriterWithExtensions

func (w *OrgWriter) WriterWithExtensions() Writer

type Outline

type Outline struct {
	*Section
	// contains filtered or unexported fields
}

type Paragraph

type Paragraph struct {
	Children []Node
	Pos      Position
}

func (Paragraph) Copy added in v1.11.3

func (n Paragraph) Copy() Node

func (Paragraph) Position added in v1.11.3

func (n Paragraph) Position() Position

func (Paragraph) Range added in v1.11.3

func (n Paragraph) Range(f func(Node) bool)

func (Paragraph) String

func (n Paragraph) String() string

type ParseError added in v1.11.1

type ParseError struct {
	Type    ErrorType
	Message string
	File    string

	// Position information
	StartLine int
	EndLine   int
	StartCol  int
	EndCol    int

	// Additional context
	Token   token  // The problematic token, if applicable
	Context string // Additional context or suggestion

	// Underlying cause
	Cause error
}

ParseError is a structured error with detailed position information. It provides precise location tracking for syntax and parsing errors.

func NewParseError added in v1.11.1

func NewParseError(typ ErrorType, message, file string, pos Position, tok token, cause error) *ParseError

NewParseError creates a new ParseError from the given components.

func (*ParseError) Error added in v1.11.1

func (e *ParseError) Error() string

Error implements the error interface with a formatted message.

func (*ParseError) String added in v1.11.1

func (e *ParseError) String() string

String provides a detailed string representation including all fields.

func (*ParseError) Unwrap added in v1.11.1

func (e *ParseError) Unwrap() error

Unwrap returns the underlying cause for error chain support.

type Position

type Position struct {
	StartLine   int
	StartColumn int
	EndLine     int
	EndColumn   int
}

Position represents the location of a node in the source text.

type PropertyDrawer

type PropertyDrawer struct {
	Properties [][]string
	Pos        Position
}

func (PropertyDrawer) Copy added in v1.11.3

func (n PropertyDrawer) Copy() Node

func (*PropertyDrawer) Get

func (d *PropertyDrawer) Get(key string) (string, bool)

func (PropertyDrawer) Position added in v1.11.3

func (n PropertyDrawer) Position() Position

func (PropertyDrawer) Range added in v1.11.3

func (n PropertyDrawer) Range(f func(Node) bool)

func (PropertyDrawer) String

func (n PropertyDrawer) String() string
type RegularLink struct {
	Protocol    string
	Description []Node
	URL         string
	AutoLink    bool
	Pos         Position
}

func (RegularLink) Copy added in v1.11.3

func (n RegularLink) Copy() Node

func (RegularLink) Kind

func (l RegularLink) Kind() string

func (RegularLink) Position added in v1.11.3

func (n RegularLink) Position() Position

func (RegularLink) Range added in v1.11.3

func (n RegularLink) Range(f func(Node) bool)

func (RegularLink) String

func (n RegularLink) String() string

type Result

type Result struct {
	Node Node
	Pos  Position
}

func (Result) Copy added in v1.11.3

func (n Result) Copy() Node

func (Result) Position added in v1.11.3

func (n Result) Position() Position

func (Result) Range added in v1.11.3

func (n Result) Range(f func(Node) bool)

func (Result) String

func (n Result) String() string

type Row

type Row struct {
	Columns   []Column
	IsSpecial bool
	Pos       Position
}

type Section

type Section struct {
	Headline *Headline
	Parent   *Section
	Children []*Section
}

type StatisticToken

type StatisticToken struct {
	Content string
	Pos     Position
}

func (StatisticToken) Copy added in v1.11.3

func (n StatisticToken) Copy() Node

func (StatisticToken) Position added in v1.11.3

func (n StatisticToken) Position() Position

func (StatisticToken) Range added in v1.11.3

func (n StatisticToken) Range(f func(Node) bool)

func (StatisticToken) String

func (n StatisticToken) String() string

type Table

type Table struct {
	Rows             []Row
	ColumnInfos      []ColumnInfo
	SeparatorIndices []int
	Pos              Position
}

func (Table) Copy added in v1.11.3

func (n Table) Copy() Node

func (Table) Position added in v1.11.3

func (n Table) Position() Position

func (Table) Range added in v1.11.3

func (n Table) Range(f func(Node) bool)

func (Table) String

func (n Table) String() string

type Text

type Text struct {
	Content string
	IsRaw   bool
	Pos     Position
}

func (Text) Copy added in v1.11.3

func (n Text) Copy() Node

func (Text) Position added in v1.11.3

func (n Text) Position() Position

func (Text) Range added in v1.11.3

func (n Text) Range(f func(Node) bool)

func (Text) String

func (n Text) String() string

type Timestamp

type Timestamp struct {
	Time     time.Time
	IsDate   bool
	Interval string
	Pos      Position
}

func (Timestamp) Copy added in v1.11.3

func (n Timestamp) Copy() Node

func (Timestamp) Position added in v1.11.3

func (n Timestamp) Position() Position

func (Timestamp) Range added in v1.11.3

func (n Timestamp) Range(f func(Node) bool)

func (Timestamp) String

func (n Timestamp) String() string

type Writer

type Writer interface {
	Before(*Document) // Before is called before any nodes are passed to the writer.
	After(*Document)  // After is called after all nodes have been passed to the writer.
	String() string   // String is called at the very end to retrieve the final output.

	WriterWithExtensions() Writer
	WriteNodesAsString(...Node) string

	WriteKeyword(Keyword)
	WriteInclude(Include)
	WriteComment(Comment)
	WriteNodeWithMeta(NodeWithMeta)
	WriteNodeWithName(NodeWithName)
	WriteHeadline(Headline)
	WriteBlock(Block)
	WriteResult(Result)
	WriteLatexBlock(LatexBlock)
	WriteInlineBlock(InlineBlock)
	WriteExample(Example)
	WriteDrawer(Drawer)
	WritePropertyDrawer(PropertyDrawer)
	WriteList(List)
	WriteListItem(ListItem)
	WriteDescriptiveListItem(DescriptiveListItem)
	WriteTable(Table)
	WriteHorizontalRule(HorizontalRule)
	WriteParagraph(Paragraph)
	WriteText(Text)
	WriteEmphasis(Emphasis)
	WriteLatexFragment(LatexFragment)
	WriteStatisticToken(StatisticToken)
	WriteExplicitLineBreak(ExplicitLineBreak)
	WriteLineBreak(LineBreak)
	WriteRegularLink(RegularLink)
	WriteMacro(Macro)
	WriteTimestamp(Timestamp)
	WriteFootnoteLink(FootnoteLink)
	WriteFootnoteDefinition(FootnoteDefinition)
}

Writer is the interface that is used to export a parsed document into a new format. See Document.Write().

Jump to

Keyboard shortcuts

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