WikitextEx.AST (WikitextEx v0.1.1)
View SourceAbstract Syntax Tree (AST) structure for WikitextEx parser.
This module defines the AST node structure and all the specific node types that represent different wikitext elements. Each AST node has:
type
: An atom indicating the kind of element (:text
,:template
,:link
, etc.)value
: Type-specific data stored in structured formatchildren
: List of nested AST nodes for container elements
Example
%WikitextEx.AST{
type: :template,
value: %WikitextEx.AST.Template{name: "cite", args: [...]},
children: []
}
Node Types
The parser produces these AST node types:
- Text elements:
:text
- Structure:
:header
,:list_item
,:table
,:table_row
,:table_cell
- Formatting:
:bold
,:italic
- Links:
:link
,:category
,:file
,:interlang_link
- Templates:
:template
- HTML:
:html_tag
,:comment
,:ref
,:nowiki
Summary
Functions
Extract text content from AST children, useful for headers and other containers.
Types
@type type() :: atom()
@type value() :: WikitextEx.AST.Header.t() | WikitextEx.AST.Text.t() | WikitextEx.AST.Template.t() | WikitextEx.AST.Link.t() | WikitextEx.AST.Category.t() | WikitextEx.AST.InterlangLink.t() | WikitextEx.AST.HtmlTag.t() | WikitextEx.AST.ListItem.t() | WikitextEx.AST.Comment.t() | WikitextEx.AST.Ref.t() | WikitextEx.AST.Nowiki.t() | WikitextEx.AST.Table.t() | WikitextEx.AST.TableRow.t() | WikitextEx.AST.TableCell.t() | nil
Functions
Extract text content from AST children, useful for headers and other containers.
Examples
iex> children = [
...> %WikitextEx.AST{type: :text, value: %WikitextEx.AST.Text{content: "Hello"}, children: []},
...> %WikitextEx.AST{type: :text, value: %WikitextEx.AST.Text{content: " World"}, children: []}
...> ]
iex> WikitextEx.AST.text_content(children)
"Hello World"
iex> node = %WikitextEx.AST{type: :text, value: %WikitextEx.AST.Text{content: "Single text"}, children: []}
iex> WikitextEx.AST.text_content(node)
"Single text"
iex> bold_node = %WikitextEx.AST{
...> type: :bold,
...> value: nil,
...> children: [%WikitextEx.AST{type: :text, value: %WikitextEx.AST.Text{content: "Bold text"}, children: []}]
...> }
iex> WikitextEx.AST.text_content(bold_node)
"Bold text"