org v0.1.0 Org.Table
Represents a table.
Example:
iex> source = "| *Foo* | *Bar* |\n|-------+-------|\n| 123 | 456 |"
iex> doc = Org.Parser.parse(source)
iex> [table] = Org.tables(doc)
iex> Enum.at(table.rows, 0)
%Org.Table.Row{cells: ["*Foo*", "*Bar*"]}
iex> Enum.at(table.rows, 1)
%Org.Table.Separator{}
iex> Enum.at(table.rows, 2)
%Org.Table.Row{cells: ["123", "456"]}
Link to this section Summary
Link to this section Types
Link to this section Functions
Returns a list of rows with cells named according to given keys.
Example:
iex> table = Org.Table.new([["Width", "20"], ["Height", "40"]])
iex> Org.Table.extract_rows(table, [:parameter_name, :value])
[%{parameter_name: "Width", value: "20"}, %{parameter_name: "Height", value: "40"}]
Constructs a new table, with given initial rows.
The rows can either be Org.Table.Row / Org.Table.Separator structs or will be interpreted from a list of cell contents.
Creating a table from plain cell contents:
iex> table = Org.Table.new([["foo", "bar"]])
iex> table.rows
[%Org.Table.Row{cells: ["foo", "bar"]}]
Creating a table from row structures:
iex> table = Org.Table.new([%Org.Table.Row{cells: ["foo", "bar"]}])
iex> table.rows
[%Org.Table.Row{cells: ["foo", "bar"]}]
Creating a table from a mixture of structures and cell contents:
iex> table = Org.Table.new([["foo"], %Org.Table.Separator{}, ["bar"]])
iex> table.rows
[%Org.Table.Row{cells: ["foo"]}, %Org.Table.Separator{}, %Org.Table.Row{cells: ["bar"]}]
Prepends a row to the table. The row will be cast the same way as when passed to new/1
.
This function is used by the parser, which builds up documents in reverse and then finally calls Org.Content.reverse_recursive/1 to yield the original order.
Returns a table with the given number of leading rows omitted.
Example:
iex> table = Org.Table.new([["X", "Y"], ["7", "4"], ["3", "8"], ["15", "24"]])
iex> Org.Table.skip_rows(table, 1)
%Org.Table{rows: [%Org.Table.Row{cells: ["7", "4"]}, %Org.Table.Row{cells: ["3", "8"]}, %Org.Table.Row{cells: ["15", "24"]}]}