Utilities for working with Quillon AST nodes.
Provides accessors, type guards, and predicates for node tuples.
Summary
Functions
Get the attrs of a node.
Check if a node is a block type.
Check if a node is a blockquote.
Check if a node is a bullet list.
Check if a node is a callout.
Get the children of a node.
Check if a node is a code block.
Check if a node is a container type.
Check if a node is a divider.
Check if a node is a document.
Check if a node is a heading.
Check if a node is an image.
Check if a node is an inline type.
Check if a node is a list (bullet or ordered).
Check if a node is a list item.
Check if a value is a valid node tuple.
Check if a node is an ordered list.
Check if a node is a paragraph.
Check if a node is a table.
Check if a node is a table cell.
Check if a node is a table row.
Check if a node is a text node.
Get the type of a node.
Check if a node is a video.
Functions
Get the attrs of a node.
Examples
iex> Quillon.Node.attrs({:heading, %{level: 2}, []})
%{level: 2}
iex> Quillon.Node.attrs({:paragraph, %{}, []})
%{}
Check if a node is a block type.
Examples
iex> Quillon.Node.block?({:paragraph, %{}, []})
true
iex> Quillon.Node.block?({:heading, %{level: 1}, []})
true
iex> Quillon.Node.block?({:text, %{text: "Hi", marks: []}, []})
false
Check if a node is a blockquote.
Examples
iex> Quillon.Node.blockquote?({:blockquote, %{}, []})
true
iex> Quillon.Node.blockquote?({:paragraph, %{}, []})
false
Check if a node is a bullet list.
Examples
iex> Quillon.Node.bullet_list?({:bullet_list, %{}, []})
true
iex> Quillon.Node.bullet_list?({:ordered_list, %{start: 1}, []})
false
Check if a node is a callout.
Examples
iex> Quillon.Node.callout?({:callout, %{type: :info}, []})
true
iex> Quillon.Node.callout?({:paragraph, %{}, []})
false
Get the children of a node.
Examples
iex> Quillon.Node.children({:paragraph, %{}, [{:text, %{text: "Hi", marks: []}, []}]})
[{:text, %{text: "Hi", marks: []}, []}]
iex> Quillon.Node.children({:divider, %{}, []})
[]
Check if a node is a code block.
Examples
iex> Quillon.Node.code_block?({:code_block, %{code: "x = 1", language: "elixir"}, []})
true
iex> Quillon.Node.code_block?({:paragraph, %{}, []})
false
Check if a node is a container type.
Examples
iex> Quillon.Node.container?({:document, %{}, []})
true
iex> Quillon.Node.container?({:paragraph, %{}, []})
false
Check if a node is a divider.
Examples
iex> Quillon.Node.divider?({:divider, %{style: :dashed}, []})
true
iex> Quillon.Node.divider?({:paragraph, %{}, []})
false
Check if a node is a document.
Examples
iex> Quillon.Node.document?({:document, %{id: "doc_1"}, []})
true
iex> Quillon.Node.document?({:paragraph, %{}, []})
false
Check if a node is a heading.
Examples
iex> Quillon.Node.heading?({:heading, %{level: 2}, []})
true
iex> Quillon.Node.heading?({:paragraph, %{}, []})
false
Check if a node is an image.
Examples
iex> Quillon.Node.image?({:image, %{src: "/img.jpg", alt: ""}, []})
true
iex> Quillon.Node.image?({:paragraph, %{}, []})
false
Check if a node is an inline type.
Examples
iex> Quillon.Node.inline?({:text, %{text: "Hi", marks: []}, []})
true
iex> Quillon.Node.inline?({:paragraph, %{}, []})
false
Check if a node is a list (bullet or ordered).
Examples
iex> Quillon.Node.list?({:bullet_list, %{}, []})
true
iex> Quillon.Node.list?({:ordered_list, %{start: 1}, []})
true
iex> Quillon.Node.list?({:paragraph, %{}, []})
false
Check if a node is a list item.
Examples
iex> Quillon.Node.list_item?({:list_item, %{}, []})
true
iex> Quillon.Node.list_item?({:paragraph, %{}, []})
false
Check if a value is a valid node tuple.
Examples
iex> Quillon.Node.node?({:paragraph, %{}, []})
true
iex> Quillon.Node.node?({:text, %{text: "Hi", marks: []}, []})
true
iex> Quillon.Node.node?("not a node")
false
iex> Quillon.Node.node?({:paragraph, [], []})
false
Check if a node is an ordered list.
Examples
iex> Quillon.Node.ordered_list?({:ordered_list, %{start: 1}, []})
true
iex> Quillon.Node.ordered_list?({:bullet_list, %{}, []})
false
Check if a node is a paragraph.
Examples
iex> Quillon.Node.paragraph?({:paragraph, %{}, []})
true
iex> Quillon.Node.paragraph?({:heading, %{level: 1}, []})
false
Check if a node is a table.
Examples
iex> Quillon.Node.table?({:table, %{}, []})
true
iex> Quillon.Node.table?({:paragraph, %{}, []})
false
Check if a node is a table cell.
Examples
iex> Quillon.Node.table_cell?({:table_cell, %{colspan: 1, rowspan: 1}, []})
true
iex> Quillon.Node.table_cell?({:table_row, %{header: false}, []})
false
Check if a node is a table row.
Examples
iex> Quillon.Node.table_row?({:table_row, %{header: false}, []})
true
iex> Quillon.Node.table_row?({:table, %{}, []})
false
Check if a node is a text node.
Examples
iex> Quillon.Node.text?({:text, %{text: "Hello", marks: [:bold]}, []})
true
iex> Quillon.Node.text?({:paragraph, %{}, []})
false
Get the type of a node.
Examples
iex> Quillon.Node.type({:paragraph, %{}, []})
:paragraph
iex> Quillon.Node.type({:heading, %{level: 1}, []})
:heading
Check if a node is a video.
Examples
iex> Quillon.Node.video?({:video, %{src: "/vid.mp4"}, []})
true
iex> Quillon.Node.video?({:paragraph, %{}, []})
false