Factory functions for creating Quillon AST nodes.
Provides new/2 and new/3 for generic node creation, plus
convenience functions for each node type.
Summary
Functions
Create an empty blockquote.
Create a blockquote with children.
Create a blockquote with children and citation or options.
Create a blockquote with children, citation, and layout/style options.
Create an empty bullet list.
Create a bullet list with list item children.
Create a bullet list with items and layout options.
Create an empty callout with type.
Create a callout with type and children.
Create a callout with type, children, and title or layout/style options.
Create a callout with type, children, title, and layout/style options.
Create a code block with code content.
Create a code block with code and language.
Create a code block with code, language, and layout/style options.
Create a divider with default style (solid).
Create a divider with a specific style.
Create a divider with style and layout/style options.
Create an empty document.
Create a document with children.
Create a document with attrs and children.
Create an empty grid.
Create a grid with children.
Create a grid with children and layout options.
Create a heading with a level.
Create a heading with level and text content or children.
Create a heading with level, content, and layout/style options.
Create an image with src.
Create an image with src and alt.
Create an image with src, alt, and additional options.
Create an empty list item.
Create a list item with block children.
Create a new node with type and attrs, empty children.
Create a new node with type, attrs, and children.
Create an empty ordered list with start=1.
Create an ordered list with list item children.
Create an ordered list with items and custom start number or layout options.
Create an ordered list with items, custom start, and layout options.
Create an empty paragraph.
Create a paragraph with text content or children.
Create a paragraph with content and layout/style options.
Create an empty row.
Create a row with children.
Create a row with children and layout options.
Create an empty table.
Create a table with table row children.
Create a table with rows and layout/style options.
Create an empty table cell.
Create a table cell with block children.
Create a table cell with children and span options.
Create an empty table row.
Create a table row with table cell children.
Create a table row with cells and options.
Create a text node with no marks.
Create a text node with marks.
Create a video with src.
Create a video with src and options.
Functions
@spec blockquote() :: tuple()
Create an empty blockquote.
Examples
iex> Quillon.Factory.blockquote()
{:blockquote, %{}, []}
Create a blockquote with children.
Examples
iex> Quillon.Factory.blockquote([{:paragraph, %{}, [{:text, %{text: "Quote", marks: []}, []}]}])
{:blockquote, %{}, [{:paragraph, %{}, [{:text, %{text: "Quote", marks: []}, []}]}]}
Create a blockquote with children and citation or options.
When the second argument is a string, it is used as the citation. When it is a keyword list, it is used as layout/style options.
Examples
iex> Quillon.Factory.blockquote([{:paragraph, %{}, []}], "Author")
{:blockquote, %{citation: "Author"}, [{:paragraph, %{}, []}]}
iex> Quillon.Factory.blockquote([{:paragraph, %{}, []}], spacing: :lg)
{:blockquote, %{spacing: :lg}, [{:paragraph, %{}, []}]}
Create a blockquote with children, citation, and layout/style options.
Examples
iex> Quillon.Factory.blockquote([{:paragraph, %{}, []}], "Author", spacing: :lg)
{:blockquote, %{citation: "Author", spacing: :lg}, [{:paragraph, %{}, []}]}
@spec bullet_list() :: tuple()
Create an empty bullet list.
Examples
iex> Quillon.Factory.bullet_list()
{:bullet_list, %{}, []}
Create a bullet list with list item children.
Examples
iex> Quillon.Factory.bullet_list([{:list_item, %{}, [{:paragraph, %{}, []}]}])
{:bullet_list, %{}, [{:list_item, %{}, [{:paragraph, %{}, []}]}]}
Create a bullet list with items and layout options.
Examples
iex> Quillon.Factory.bullet_list([{:list_item, %{}, [{:paragraph, %{}, []}]}], spacing: :sm)
{:bullet_list, %{spacing: :sm}, [{:list_item, %{}, [{:paragraph, %{}, []}]}]}
Create an empty callout with type.
Examples
iex> Quillon.Factory.callout(:info)
{:callout, %{type: :info}, []}
iex> Quillon.Factory.callout(:warning)
{:callout, %{type: :warning}, []}
Create a callout with type and children.
Examples
iex> Quillon.Factory.callout(:info, [{:paragraph, %{}, []}])
{:callout, %{type: :info}, [{:paragraph, %{}, []}]}
Create a callout with type, children, and title or layout/style options.
When the third argument is a string, it is used as the title. When it is a keyword list, it is used as layout/style options.
Examples
iex> Quillon.Factory.callout(:warning, [{:paragraph, %{}, []}], "Note")
{:callout, %{type: :warning, title: "Note"}, [{:paragraph, %{}, []}]}
iex> Quillon.Factory.callout(:info, [{:paragraph, %{}, []}], spacing: :lg)
{:callout, %{type: :info, spacing: :lg}, [{:paragraph, %{}, []}]}
Create a callout with type, children, title, and layout/style options.
Examples
iex> Quillon.Factory.callout(:warning, [{:paragraph, %{}, []}], "Note", spacing: :sm)
{:callout, %{type: :warning, title: "Note", spacing: :sm}, [{:paragraph, %{}, []}]}
Create a code block with code content.
Examples
iex> Quillon.Factory.code_block("def hello, do: :world")
{:code_block, %{code: "def hello, do: :world", language: ""}, []}
Create a code block with code and language.
Examples
iex> Quillon.Factory.code_block("def hello, do: :world", "elixir")
{:code_block, %{code: "def hello, do: :world", language: "elixir"}, []}
Create a code block with code, language, and layout/style options.
Examples
iex> Quillon.Factory.code_block("x = 1", "elixir", width: :wide)
{:code_block, %{code: "x = 1", language: "elixir", width: :wide}, []}
@spec divider() :: tuple()
Create a divider with default style (solid).
Examples
iex> Quillon.Factory.divider()
{:divider, %{style: :solid}, []}
Create a divider with a specific style.
Examples
iex> Quillon.Factory.divider(:dashed)
{:divider, %{style: :dashed}, []}
iex> Quillon.Factory.divider(:dotted)
{:divider, %{style: :dotted}, []}
Create a divider with style and layout/style options.
Examples
iex> Quillon.Factory.divider(:dashed, spacing: :lg)
{:divider, %{style: :dashed, spacing: :lg}, []}
@spec document() :: tuple()
Create an empty document.
Examples
iex> Quillon.Factory.document()
{:document, %{}, []}
Create a document with children.
Examples
iex> Quillon.Factory.document([{:paragraph, %{}, []}])
{:document, %{}, [{:paragraph, %{}, []}]}
Create a document with attrs and children.
Examples
iex> Quillon.Factory.document(%{id: "doc_1"}, [{:paragraph, %{}, []}])
{:document, %{id: "doc_1"}, [{:paragraph, %{}, []}]}
@spec grid() :: tuple()
Create an empty grid.
Examples
iex> Quillon.Factory.grid()
{:grid, %{}, []}
Create a grid with children.
Examples
iex> Quillon.Factory.grid([{:paragraph, %{}, []}])
{:grid, %{}, [{:paragraph, %{}, []}]}
Create a grid with children and layout options.
Examples
iex> Quillon.Factory.grid([{:paragraph, %{}, []}], columns: 2, gap: :sm)
{:grid, %{columns: 2, gap: :sm}, [{:paragraph, %{}, []}]}
Create a heading with a level.
Examples
iex> Quillon.Factory.heading(1)
{:heading, %{level: 1}, []}
iex> Quillon.Factory.heading(3)
{:heading, %{level: 3}, []}
Create a heading with level and text content or children.
Examples
iex> Quillon.Factory.heading(1, "Welcome")
{:heading, %{level: 1}, [{:text, %{text: "Welcome", marks: []}, []}]}
iex> Quillon.Factory.heading(2, [{:text, %{text: "Bold", marks: [:bold]}, []}])
{:heading, %{level: 2}, [{:text, %{text: "Bold", marks: [:bold]}, []}]}
Create a heading with level, content, and layout/style options.
Examples
iex> Quillon.Factory.heading(1, "Welcome", align: :center)
{:heading, %{level: 1, align: :center}, [{:text, %{text: "Welcome", marks: []}, []}]}
Create an image with src.
Examples
iex> Quillon.Factory.image("/images/photo.jpg")
{:image, %{src: "/images/photo.jpg", alt: ""}, []}
Create an image with src and alt.
Examples
iex> Quillon.Factory.image("/images/photo.jpg", "A photo")
{:image, %{src: "/images/photo.jpg", alt: "A photo"}, []}
Create an image with src, alt, and additional options.
Options can include :caption and :width.
Examples
iex> Quillon.Factory.image("/images/photo.jpg", "A photo", caption: "Figure 1")
{:image, %{src: "/images/photo.jpg", alt: "A photo", caption: "Figure 1"}, []}
iex> Quillon.Factory.image("/images/photo.jpg", "A photo", width: 800)
{:image, %{src: "/images/photo.jpg", alt: "A photo", width: 800}, []}
@spec list_item() :: tuple()
Create an empty list item.
Examples
iex> Quillon.Factory.list_item()
{:list_item, %{}, []}
Create a list item with block children.
Examples
iex> Quillon.Factory.list_item([{:paragraph, %{}, [{:text, %{text: "Item", marks: []}, []}]}])
{:list_item, %{}, [{:paragraph, %{}, [{:text, %{text: "Item", marks: []}, []}]}]}
Create a new node with type and attrs, empty children.
Examples
iex> Quillon.Factory.new(:paragraph, %{})
{:paragraph, %{}, []}
iex> Quillon.Factory.new(:heading, %{level: 2})
{:heading, %{level: 2}, []}
Create a new node with type, attrs, and children.
When a string is passed as children, it's automatically wrapped in a text node.
Examples
iex> Quillon.Factory.new(:paragraph, %{}, [{:text, %{text: "Hi", marks: []}, []}])
{:paragraph, %{}, [{:text, %{text: "Hi", marks: []}, []}]}
iex> Quillon.Factory.new(:paragraph, %{}, "Hello")
{:paragraph, %{}, [{:text, %{text: "Hello", marks: []}, []}]}
iex> Quillon.Factory.new(:divider, %{style: :dashed}, [])
{:divider, %{style: :dashed}, []}
@spec ordered_list() :: tuple()
Create an empty ordered list with start=1.
Examples
iex> Quillon.Factory.ordered_list()
{:ordered_list, %{start: 1}, []}
Create an ordered list with list item children.
Examples
iex> Quillon.Factory.ordered_list([{:list_item, %{}, [{:paragraph, %{}, []}]}])
{:ordered_list, %{start: 1}, [{:list_item, %{}, [{:paragraph, %{}, []}]}]}
Create an ordered list with items and custom start number or layout options.
When the second argument is an integer, it is used as the start number. When it is a keyword list, it is used as layout options.
Examples
iex> Quillon.Factory.ordered_list([{:list_item, %{}, []}], 5)
{:ordered_list, %{start: 5}, [{:list_item, %{}, []}]}
iex> Quillon.Factory.ordered_list([{:list_item, %{}, []}], spacing: :sm)
{:ordered_list, %{start: 1, spacing: :sm}, [{:list_item, %{}, []}]}
Create an ordered list with items, custom start, and layout options.
Examples
iex> Quillon.Factory.ordered_list([{:list_item, %{}, []}], 5, spacing: :lg)
{:ordered_list, %{start: 5, spacing: :lg}, [{:list_item, %{}, []}]}
@spec paragraph() :: tuple()
Create an empty paragraph.
Examples
iex> Quillon.Factory.paragraph()
{:paragraph, %{}, []}
Create a paragraph with text content or children.
Examples
iex> Quillon.Factory.paragraph("Hello world")
{:paragraph, %{}, [{:text, %{text: "Hello world", marks: []}, []}]}
iex> Quillon.Factory.paragraph([{:text, %{text: "Hi", marks: [:bold]}, []}])
{:paragraph, %{}, [{:text, %{text: "Hi", marks: [:bold]}, []}]}
Create a paragraph with content and layout/style options.
Examples
iex> Quillon.Factory.paragraph("Hello", align: :center)
{:paragraph, %{align: :center}, [{:text, %{text: "Hello", marks: []}, []}]}
iex> Quillon.Factory.paragraph("Hello", align: :center, spacing: :lg)
{:paragraph, %{align: :center, spacing: :lg}, [{:text, %{text: "Hello", marks: []}, []}]}
iex> Quillon.Factory.paragraph([{:text, %{text: "Hi", marks: []}, []}], font_size: :sm)
{:paragraph, %{font_size: :sm}, [{:text, %{text: "Hi", marks: []}, []}]}
@spec row() :: tuple()
Create an empty row.
Examples
iex> Quillon.Factory.row()
{:row, %{}, []}
Create a row with children.
Examples
iex> Quillon.Factory.row([{:paragraph, %{}, []}])
{:row, %{}, [{:paragraph, %{}, []}]}
Create a row with children and layout options.
Examples
iex> Quillon.Factory.row([{:paragraph, %{}, []}], justify: :between, gap: :md)
{:row, %{justify: :between, gap: :md}, [{:paragraph, %{}, []}]}
@spec table() :: tuple()
Create an empty table.
Examples
iex> Quillon.Factory.table()
{:table, %{}, []}
Create a table with table row children.
Examples
iex> Quillon.Factory.table([{:table_row, %{header: false}, []}])
{:table, %{}, [{:table_row, %{header: false}, []}]}
Create a table with rows and layout/style options.
Examples
iex> Quillon.Factory.table([{:table_row, %{header: false}, []}], width: :wide)
{:table, %{width: :wide}, [{:table_row, %{header: false}, []}]}
@spec table_cell() :: tuple()
Create an empty table cell.
Examples
iex> Quillon.Factory.table_cell()
{:table_cell, %{colspan: 1, rowspan: 1}, []}
Create a table cell with block children.
Examples
iex> Quillon.Factory.table_cell([{:paragraph, %{}, []}])
{:table_cell, %{colspan: 1, rowspan: 1}, [{:paragraph, %{}, []}]}
Create a table cell with children and span options.
Options can include :colspan and :rowspan.
Examples
iex> Quillon.Factory.table_cell([{:paragraph, %{}, []}], colspan: 2)
{:table_cell, %{colspan: 2, rowspan: 1}, [{:paragraph, %{}, []}]}
iex> Quillon.Factory.table_cell([{:paragraph, %{}, []}], rowspan: 3)
{:table_cell, %{colspan: 1, rowspan: 3}, [{:paragraph, %{}, []}]}
iex> Quillon.Factory.table_cell([{:paragraph, %{}, []}], colspan: 2, rowspan: 2)
{:table_cell, %{colspan: 2, rowspan: 2}, [{:paragraph, %{}, []}]}
@spec table_row() :: tuple()
Create an empty table row.
Examples
iex> Quillon.Factory.table_row()
{:table_row, %{header: false}, []}
Create a table row with table cell children.
Examples
iex> Quillon.Factory.table_row([{:table_cell, %{colspan: 1, rowspan: 1}, []}])
{:table_row, %{header: false}, [{:table_cell, %{colspan: 1, rowspan: 1}, []}]}
Create a table row with cells and options.
Options can include :header (boolean).
Examples
iex> Quillon.Factory.table_row([{:table_cell, %{colspan: 1, rowspan: 1}, []}], header: true)
{:table_row, %{header: true}, [{:table_cell, %{colspan: 1, rowspan: 1}, []}]}
Create a text node with no marks.
Examples
iex> Quillon.Factory.text("Hello")
{:text, %{text: "Hello", marks: []}, []}
Create a text node with marks.
Examples
iex> Quillon.Factory.text("Bold text", [:bold])
{:text, %{text: "Bold text", marks: [:bold]}, []}
iex> Quillon.Factory.text("Link", [{:link, %{href: "/page"}}])
{:text, %{text: "Link", marks: [{:link, %{href: "/page"}}]}, []}
Create a video with src.
Examples
iex> Quillon.Factory.video("/videos/clip.mp4")
{:video, %{src: "/videos/clip.mp4"}, []}
Create a video with src and options.
Options can include :poster.
Examples
iex> Quillon.Factory.video("/videos/clip.mp4", poster: "/images/poster.jpg")
{:video, %{src: "/videos/clip.mp4", poster: "/images/poster.jpg"}, []}