org v0.1.0 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 Functions
contents(Org.Document.t() | Org.Section.t()) :: [Org.Content.t()]
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
Example:
iex> doc = Org.load_string("First paragraph\n| x | y |\n| 1 | 7 |\nSecond 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("* First\n** Second\n*** Third\n* Fourth\n")
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.Paragraph.t()]
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("First paragraph\n| x | y |\n| 1 | 7 |\nSecond paragraph")
iex> Org.tables(doc)
[%Org.Table{rows: [%Org.Table.Row{cells: ["x", "y"]}, %Org.Table.Row{cells: ["1", "7"]}]}]