Current section

Files

Jump to
html_to_markdown lib html_to_markdown node_content.ex
Raw

lib/html_to_markdown/node_content.ex

# This file is auto-generated by alef — DO NOT EDIT.
# alef:hash:ae27fb2270a21feb95d12e56306ee8cb658cb16e6b0de1fb02eef725f0889bb7
# To regenerate: alef generate
# To verify freshness: alef verify --exit-code
defmodule HtmlToMarkdown.NodeContent do
@moduledoc """
The semantic content type of a document node.
Uses internally tagged representation (`"node_type": "heading"`) for JSON serialization.
"""
@typedoc "The semantic content type of a document node."
@type t :: term()
@typedoc "A heading element (h1-h6)."
@type heading :: %{type: :heading, level: non_neg_integer(), text: String.t()}
@typedoc "A paragraph of text."
@type paragraph :: %{type: :paragraph, text: String.t()}
@typedoc "A list container (ordered or unordered). Children are `ListItem` nodes."
@type list_variant :: %{type: :list, ordered: boolean()}
@typedoc "A single list item."
@type list_item :: %{type: :list_item, text: String.t()}
@typedoc "A table with structured cell data."
@type table :: %{type: :table, grid: HtmlToMarkdown.TableGrid.t()}
@typedoc "An image element."
@type image :: %{type: :image, description: String.t(), src: String.t(), image_index: non_neg_integer()}
@typedoc "A code block or inline code."
@type code :: %{type: :code, text: String.t(), language: String.t()}
@typedoc "A block quote container."
@type quote :: :quote
@typedoc "A definition list container."
@type definition_list :: :definition_list
@typedoc "A definition list entry with term and description."
@type definition_item :: %{type: :definition_item, term: String.t(), definition: String.t()}
@typedoc "A raw block preserved as-is (e.g. `<script>`, `<style>` content)."
@type raw_block :: %{type: :raw_block, format: String.t(), content: String.t()}
@typedoc "A block of key-value metadata pairs (from `<head>` meta tags)."
@type metadata_block :: %{type: :metadata_block, entries: [map()]}
@typedoc "A section grouping container (auto-generated from heading hierarchy)."
@type group :: %{type: :group, label: String.t(), heading_level: non_neg_integer(), heading_text: String.t()}
def heading(level, text), do: {:heading, %{level: level, text: text}}
def paragraph(text), do: {:paragraph, %{text: text}}
def list(ordered), do: {:list, %{ordered: ordered}}
def list_item(text), do: {:list_item, %{text: text}}
def table(grid), do: {:table, %{grid: grid}}
def image(description, src, image_index), do: {:image, %{description: description, src: src, image_index: image_index}}
def code(text, language), do: {:code, %{text: text, language: language}}
def definition_item(term, definition), do: {:definition_item, %{term: term, definition: definition}}
def raw_block(format, content), do: {:raw_block, %{format: format, content: content}}
def metadata_block(entries), do: {:metadata_block, %{entries: entries}}
def group(label, heading_level, heading_text), do: {:group, %{label: label, heading_level: heading_level, heading_text: heading_text}}
end