org v0.1.1 Org
This package implements an org-mode lexer and parser.
org-mode is the markup language used by the powerful org mode package for emacs.
This implementation supports only a small subset of the syntax at this point, but can already be useful for extracting information from well-formed documents.
Features supported are:
- Comments
- (nested) Sections
- Paragraphs
- Tables
Link to this section Summary
Functions
Extracts all contents from given section or document
Loads a document from a file at given path
Loads a document from the given source string
Extracts all paragraphs from the given section or document
Extracts a section at the given path of titles
Extracts all tables from the given section or document
Link to this section Types
Link to this section Functions
contents(Org.Document.t() | Org.Section.t()) :: [Org.Content.t()]
Extracts all contents from given section or document
load_file(String.t(), load_mode()) :: Org.Document.t()
Loads a document from a file at given path
load_string(String.t(), load_mode()) :: Org.Document.t()
Loads a document from the given source string
paragraphs(Org.Section.t() | Org.Document.t()) :: [Org.Paragraph.t()]
Extracts all paragraphs from the given section or document
Example:
iex> doc = Org.load_string(~S{
...>First paragraph
...>| x | y |
...>| 1 | 7 |
...>Second paragraph
...>})
iex> Org.paragraphs(doc)
[%Org.Paragraph{lines: ["First paragraph"]}, %Org.Paragraph{lines: ["Second paragraph"]}]
Extracts a section at the given path of titles
Example:
iex> doc = Org.load_string(~S{
...>* First
...>** Second
...>*** Third
...>* Fourth
iex>})
iex> Org.section(doc, ["First"]).title
"First"
iex> Org.section(doc, ["First", "Second", "Third"]).title
"Third"
iex> Org.section(doc, ["Fourth"]).title
"Fourth"
tables(Org.Section.t() | Org.Document.t()) :: [Org.Table.t()]
Extracts all tables from the given section or document
Example:
iex> doc = Org.load_string(~S{
...>First paragraph
...>| x | y |
...>| 1 | 7 |
...>Second paragraph
...>})
iex> Org.tables(doc)
[%Org.Table{rows: [%Org.Table.Row{cells: ["x", "y"]}, %Org.Table.Row{cells: ["1", "7"]}]}]