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 ¶
- func String(nodes []Node) string
- func WriteNodes(w Writer, nodes ...Node)
- type Block
- type Column
- type ColumnInfo
- type Comment
- type Configuration
- type DescriptiveListItem
- type Document
- type Drawer
- type Emphasis
- type Example
- type ExplicitLineBreak
- type FootnoteDefinition
- type FootnoteLink
- type HTMLWriter
- func (w *HTMLWriter) After(d *Document)
- func (w *HTMLWriter) Before(d *Document)
- func (w *HTMLWriter) WriteBlock(b Block)
- func (w *HTMLWriter) WriteComment(Comment)
- func (w *HTMLWriter) WriteDescriptiveListItem(di DescriptiveListItem)
- func (w *HTMLWriter) WriteDrawer(d Drawer)
- func (w *HTMLWriter) WriteEmphasis(e Emphasis)
- func (w *HTMLWriter) WriteExample(e Example)
- func (w *HTMLWriter) WriteExplicitLineBreak(l ExplicitLineBreak)
- func (w *HTMLWriter) WriteFootnoteDefinition(f FootnoteDefinition)
- func (w *HTMLWriter) WriteFootnoteLink(l FootnoteLink)
- func (w *HTMLWriter) WriteFootnotes(d *Document)
- func (w *HTMLWriter) WriteHeadline(h Headline)
- func (w *HTMLWriter) WriteHorizontalRule(h HorizontalRule)
- func (w *HTMLWriter) WriteInclude(i Include)
- func (w *HTMLWriter) WriteKeyword(k Keyword)
- func (w *HTMLWriter) WriteLineBreak(l LineBreak)
- func (w *HTMLWriter) WriteList(l List)
- func (w *HTMLWriter) WriteListItem(li ListItem)
- func (w *HTMLWriter) WriteNodeWithMeta(n NodeWithMeta)
- func (w *HTMLWriter) WriteOutline(d *Document)
- func (w *HTMLWriter) WriteParagraph(p Paragraph)
- func (w *HTMLWriter) WritePropertyDrawer(PropertyDrawer)
- func (w *HTMLWriter) WriteRegularLink(l RegularLink)
- func (w *HTMLWriter) WriteStatisticToken(s StatisticToken)
- func (w *HTMLWriter) WriteTable(t Table)
- func (w *HTMLWriter) WriteText(t Text)
- func (w *HTMLWriter) WriteTimestamp(t Timestamp)
- type Headline
- type HorizontalRule
- type Include
- type Keyword
- type LineBreak
- type List
- type ListItem
- type Metadata
- type Node
- type NodeWithMeta
- type OrgWriter
- func (w *OrgWriter) After(d *Document)
- func (w *OrgWriter) Before(d *Document)
- func (w *OrgWriter) WriteBlock(b Block)
- func (w *OrgWriter) WriteComment(c Comment)
- func (w *OrgWriter) WriteDescriptiveListItem(di DescriptiveListItem)
- func (w *OrgWriter) WriteDrawer(d Drawer)
- func (w *OrgWriter) WriteEmphasis(e Emphasis)
- func (w *OrgWriter) WriteExample(e Example)
- func (w *OrgWriter) WriteExplicitLineBreak(l ExplicitLineBreak)
- func (w *OrgWriter) WriteFootnoteDefinition(f FootnoteDefinition)
- func (w *OrgWriter) WriteFootnoteLink(l FootnoteLink)
- func (w *OrgWriter) WriteHeadline(h Headline)
- func (w *OrgWriter) WriteHorizontalRule(hr HorizontalRule)
- func (w *OrgWriter) WriteInclude(i Include)
- func (w *OrgWriter) WriteKeyword(k Keyword)
- func (w *OrgWriter) WriteLineBreak(l LineBreak)
- func (w *OrgWriter) WriteList(l List)
- func (w *OrgWriter) WriteListItem(li ListItem)
- func (w *OrgWriter) WriteNodeWithMeta(n NodeWithMeta)
- func (w *OrgWriter) WriteParagraph(p Paragraph)
- func (w *OrgWriter) WritePropertyDrawer(d PropertyDrawer)
- func (w *OrgWriter) WriteRegularLink(l RegularLink)
- func (w *OrgWriter) WriteStatisticToken(s StatisticToken)
- func (w *OrgWriter) WriteTable(t Table)
- func (w *OrgWriter) WriteText(t Text)
- func (w *OrgWriter) WriteTimestamp(t Timestamp)
- type Outline
- type Paragraph
- type PropertyDrawer
- type RegularLink
- type Row
- type Section
- type StatisticToken
- type Table
- type Text
- type Timestamp
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func String ¶
String returns the pretty printed Org mode string for the given nodes (see OrgWriter).
func WriteNodes ¶
Types ¶
type Column ¶
type Column struct { Children []Node *ColumnInfo }
type ColumnInfo ¶
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. }
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 ¶
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). Nodes []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. Error error // contains filtered or unexported fields }
Document contains the parsing results and a pointer to the Configuration.
func (*Document) Get ¶
Get returns the value for key in BufferSettings or DefaultSettings if key does not exist in the former
func (*Document) GetOption ¶
GetOption returns the value associated to the export option key Currently supported options: - < (export timestamps) - e (export org entities) - f (export footnotes) - toc (export table of content) - todo (export headline todo status) - pri (export headline priority) - tags (export headline tags) see https://orgmode.org/manual/Export-settings.html for more information
type ExplicitLineBreak ¶
type ExplicitLineBreak struct{}
func (ExplicitLineBreak) String ¶
func (n ExplicitLineBreak) String() string
type FootnoteDefinition ¶
func (FootnoteDefinition) String ¶
func (n FootnoteDefinition) String() string
type FootnoteLink ¶
type FootnoteLink struct { Name string Definition *FootnoteDefinition }
func (FootnoteLink) String ¶
func (n FootnoteLink) String() string
type HTMLWriter ¶
type HTMLWriter struct { strings.Builder HighlightCodeBlock func(source, lang string) string // 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 (*HTMLWriter) WriteFootnoteLink ¶
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) WriteKeyword ¶
func (w *HTMLWriter) WriteKeyword(k Keyword)
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) WriteNodeWithMeta ¶
func (w *HTMLWriter) WriteNodeWithMeta(n NodeWithMeta)
func (*HTMLWriter) WriteOutline ¶
func (w *HTMLWriter) WriteOutline(d *Document)
func (*HTMLWriter) WriteParagraph ¶
func (w *HTMLWriter) WriteParagraph(p Paragraph)
func (*HTMLWriter) WritePropertyDrawer ¶
func (w *HTMLWriter) WritePropertyDrawer(PropertyDrawer)
func (*HTMLWriter) WriteRegularLink ¶
func (w *HTMLWriter) WriteRegularLink(l RegularLink)
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)
type Headline ¶
type HorizontalRule ¶
type HorizontalRule struct{}
func (HorizontalRule) String ¶
func (n HorizontalRule) String() string
type Node ¶
type Node interface {
String() string // String returns the pretty printed Org mode string for the node (see OrgWriter).
}
Node represents a parsed node of the document.
type NodeWithMeta ¶
func (NodeWithMeta) String ¶
func (n NodeWithMeta) String() string
type OrgWriter ¶
OrgWriter export an org document into pretty printed org document.
func NewOrgWriter ¶
func NewOrgWriter() *OrgWriter
func (*OrgWriter) WriteBlock ¶
func (*OrgWriter) WriteComment ¶
func (*OrgWriter) WriteDescriptiveListItem ¶
func (w *OrgWriter) WriteDescriptiveListItem(di DescriptiveListItem)
func (*OrgWriter) WriteDrawer ¶
func (*OrgWriter) WriteEmphasis ¶
func (*OrgWriter) WriteExample ¶
func (*OrgWriter) WriteExplicitLineBreak ¶
func (w *OrgWriter) WriteExplicitLineBreak(l ExplicitLineBreak)
func (*OrgWriter) WriteFootnoteDefinition ¶
func (w *OrgWriter) WriteFootnoteDefinition(f FootnoteDefinition)
func (*OrgWriter) WriteFootnoteLink ¶
func (w *OrgWriter) WriteFootnoteLink(l FootnoteLink)
func (*OrgWriter) WriteHeadline ¶
func (*OrgWriter) WriteHorizontalRule ¶
func (w *OrgWriter) WriteHorizontalRule(hr HorizontalRule)
func (*OrgWriter) WriteInclude ¶
func (*OrgWriter) WriteKeyword ¶
func (*OrgWriter) WriteLineBreak ¶
func (*OrgWriter) WriteListItem ¶
func (*OrgWriter) WriteNodeWithMeta ¶
func (w *OrgWriter) WriteNodeWithMeta(n NodeWithMeta)
func (*OrgWriter) WriteParagraph ¶
func (*OrgWriter) WritePropertyDrawer ¶
func (w *OrgWriter) WritePropertyDrawer(d PropertyDrawer)
func (*OrgWriter) WriteRegularLink ¶
func (w *OrgWriter) WriteRegularLink(l RegularLink)
func (*OrgWriter) WriteStatisticToken ¶
func (w *OrgWriter) WriteStatisticToken(s StatisticToken)
func (*OrgWriter) WriteTable ¶
func (*OrgWriter) WriteTimestamp ¶
type PropertyDrawer ¶
type PropertyDrawer struct {
Properties [][]string
}
func (PropertyDrawer) String ¶
func (n PropertyDrawer) String() string
type RegularLink ¶
func (RegularLink) Kind ¶
func (l RegularLink) Kind() string
func (RegularLink) String ¶
func (n RegularLink) String() string
type StatisticToken ¶
type StatisticToken struct{ Content string }
func (StatisticToken) String ¶
func (n StatisticToken) String() string
type Table ¶
type Table struct { Rows []Row ColumnInfos []ColumnInfo }
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. WriteKeyword(Keyword) WriteInclude(Include) WriteComment(Comment) WriteNodeWithMeta(NodeWithMeta) WriteHeadline(Headline) WriteBlock(Block) WriteExample(Example) WriteDrawer(Drawer) WritePropertyDrawer(PropertyDrawer) WriteList(List) WriteListItem(ListItem) WriteDescriptiveListItem(DescriptiveListItem) WriteTable(Table) WriteHorizontalRule(HorizontalRule) WriteParagraph(Paragraph) WriteText(Text) WriteEmphasis(Emphasis) WriteStatisticToken(StatisticToken) WriteExplicitLineBreak(ExplicitLineBreak) WriteLineBreak(LineBreak) WriteRegularLink(RegularLink) 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().