moonbit-community/html/src does not have a README file

    Attribute

    pub(all) struct Attribute {
    name : String
    value : String
    } derive(Eq,
    Debug
    )

    Attribute in a start/end tag
    impl Show for Attribute

    Attribute::equal

    fn Attribute::equal(Attribute, Attribute) -> Bool

    Attribute::not_equal

    fn Attribute::not_equal(x : Attribute, y : Attribute) -> Bool

    Attribute::output

    fn Attribute::output(self : Attribute, logger : &Logger) -> Unit

    Attribute::to_string

    fn Attribute::to_string(self : Attribute) -> String

    Document

    pub struct Document {
    nodes : Array[Node]
    parents : Array[Int]
    document_element : Int
    head_element : Int
    body_element : Int
    quirks_mode : QuirksMode
    scripting_enabled : Bool
    } derive(Eq,
    Debug
    )

    The complete document owns all nodes in a flat array
    impl Show for Document

    Document::add_node

    fn Document::add_node(self : Document, node : Node) -> Int

    Add a new node and return its ID

    Document::append_child

    fn Document::append_child(self : Document, parent_id : Int, child_id : Int) -> Unit

    Append a child node to a parent

    Document::dump

    fn Document::dump(self : Document) -> String

    Dump document in html5lib-tests format for conformance testing

    Document::equal

    fn Document::equal(Document, Document) -> Bool

    Document::get_attribute

    fn Document::get_attribute(self : Document, id : Int, attr_name : String) -> String?

    Get an attribute value from an element

    Document::get_children

    fn Document::get_children(self : Document, id : Int) -> Array[Int]

    Get children of a node

    Document::get_element

    fn Document::get_element(self : Document, id : Int) -> Element?

    Get an element by ID (returns None if not an element)

    Document::get_node

    fn Document::get_node(self : Document, id : Int) -> Node?

    Get a node by ID

    Document::get_ns

    fn Document::get_ns(self : Document, id : Int) -> Namespace?

    Get the namespace of an element node

    Document::get_parent

    fn Document::get_parent(self : Document, id : Int) -> Int

    Get the parent of a node

    Document::get_tag_name

    fn Document::get_tag_name(self : Document, id : Int) -> String?

    Get the tag name of an element node

    Document::get_template_content

    fn Document::get_template_content(self : Document, id : Int) -> Int

    Get the template content of a template element

    Document::get_text_content

    fn Document::get_text_content(self : Document, id : Int) -> String

    Get text content of a node (concatenation of all text descendants)

    Document::has_attribute

    fn Document::has_attribute(self : Document, id : Int, attr_name : String) -> Bool

    Check if an element has a specific attribute

    Document::insert_before

    fn Document::insert_before(self : Document, parent_id : Int, child_id : Int, reference_id : Int) -> Unit

    Insert a child node before another child

    Document::is_element

    fn Document::is_element(self : Document, id : Int, tag_name : String, ns : Namespace) -> Bool

    Check if a node is an element with the given tag name and namespace

    Document::is_html_element

    fn Document::is_html_element(self : Document, id : Int, tag_name : String) -> Bool

    Check if a node is an HTML element with the given tag name

    Document::new

    fn Document::new() -> Document

    Create a new empty document

    Document::not_equal

    fn Document::not_equal(x : Document, y : Document) -> Bool

    Document::output

    fn Document::output(self : Document, logger : &Logger) -> Unit

    Document::remove_child

    fn Document::remove_child(self : Document, parent_id : Int, child_id : Int) -> Unit

    Remove a child from its parent

    Document::set_attribute

    fn Document::set_attribute(self : Document, id : Int, attr_name : String, attr_value : String) -> Unit

    Set an attribute on an element

    Document::to_html

    fn Document::to_html(self : Document) -> String

    Serialize document to HTML string

    Document::to_repr

    Document::to_string

    fn Document::to_string(self : Document) -> String

    Element

    pub struct Element {
    tag_name : String
    ns : Namespace
    attributes : Array[(String, String)]
    children : Array[Int]
    parent : Int
    is_html_integration_point : Bool
    is_mathml_text_integration_point : Bool
    template_content : Int
    } derive(Eq,
    Debug
    )

    DOM Element node
    impl Show for Element

    Element::equal

    fn Element::equal(Element, Element) -> Bool

    Element::new

    fn Element::new(tag_name : String, ns : Namespace, attributes : Array[(String, String)]) -> Element

    Create a new Element

    Element::not_equal

    fn Element::not_equal(x : Element, y : Element) -> Bool

    Element::output

    fn Element::output(self : Element, logger : &Logger) -> Unit

    Element::to_repr

    Element::to_string

    fn Element::to_string(self : Element) -> String

    FormattingEntry

    type FormattingEntry

    Marker or Element entry in the active formatting elements list

    InsertionMode

    type InsertionMode

    23 tree construction insertion modes (WHATWG 13.2.6)

    Namespace

    pub(all) enum Namespace {
    HTML
    SVG
    MathML
    } derive(Eq,
    Debug
    )

    Namespace for HTML, SVG, MathML
    impl Show for Namespace

    Namespace::equal

    fn Namespace::equal(Namespace, Namespace) -> Bool

    Namespace::not_equal

    fn Namespace::not_equal(x : Namespace, y : Namespace) -> Bool

    Namespace::output

    fn Namespace::output(self : Namespace, logger : &Logger) -> Unit

    Namespace::to_string

    fn Namespace::to_string(self : Namespace) -> String

    Node

    pub enum Node {
    ElementNode(Element)
    TextNode(String)
    CommentNode(String)
    ProcessingInstructionNode(target~ : String, data~ : String)
    DocumentTypeNode(name~ : String, public_id~ : String, system_id~ : String)
    DocumentNode(children~ : Array[Int])
    DocumentFragmentNode(children~ : Array[Int])
    } derive(Eq,
    Debug
    )

    DOM Node - sum type for all node kinds
    impl Show for Node

    Node::equal

    fn Node::equal(Node, Node) -> Bool

    Node::not_equal

    fn Node::not_equal(x : Node, y : Node) -> Bool

    Node::output

    fn Node::output(self : Node, logger : &Logger) -> Unit

    Node::to_repr

    Node::to_string

    fn Node::to_string(self : Node) -> String

    ParseError

    pub struct ParseError {
    code : ParseErrorCode
    position : SourcePosition
    } derive(Eq,
    Debug
    )

    A parse error with location
    impl Show for ParseError

    ParseError::equal

    fn ParseError::equal(ParseError, ParseError) -> Bool

    ParseError::not_equal

    fn ParseError::not_equal(x : ParseError, y : ParseError) -> Bool

    ParseError::output

    fn ParseError::output(self : ParseError, logger : &Logger) -> Unit

    ParseError::to_string

    fn ParseError::to_string(self : ParseError) -> String

    ParseErrorCode

    pub(all) enum ParseErrorCode {
    AbruptClosingOfEmptyComment
    EofInComment
    IncorrectlyClosedComment
    IncorrectlyOpenedComment
    NestedComment
    AbruptDoctypePublicIdentifier
    AbruptDoctypeSystemIdentifier
    EofInDoctype
    InvalidCharacterSequenceAfterDoctypeName
    MissingDoctypeName
    MissingDoctypePublicIdentifier
    MissingDoctypeSystemIdentifier
    MissingQuoteBeforeDoctypePublicIdentifier
    MissingQuoteBeforeDoctypeSystemIdentifier
    MissingWhitespaceAfterDoctypePublicKeyword
    MissingWhitespaceAfterDoctypeSystemKeyword
    MissingWhitespaceBeforeDoctypeName
    MissingWhitespaceBetweenDoctypePublicAndSystemIdentifiers
    UnexpectedCharacterAfterDoctypeSystemIdentifier
    DuplicateAttribute
    EndTagWithAttributes
    EndTagWithTrailingSolidus
    EofBeforeTagName
    EofInTag
    InvalidFirstCharacterOfTagName
    MissingAttributeValue
    MissingEndTagName
    MissingWhitespaceBetweenAttributes
    NonVoidHtmlElementStartTagWithTrailingSolidus
    UnexpectedCharacterInAttributeName
    UnexpectedCharacterInUnquotedAttributeValue
    UnexpectedEqualsSignBeforeAttributeName
    UnexpectedNullCharacter
    UnexpectedQuestionMarkInsteadOfTagName
    UnexpectedSolidusInTag
    DisallowedProcessingInstructionTarget
    EofInProcessingInstruction
    InvalidFirstCharacterOfProcessingInstructionTarget
    InvalidProcessingInstructionTarget
    TreeConstruction
    AbsenceOfDigitsInNumericCharacterReference
    CharacterReferenceOutsideUnicodeRange
    ControlCharacterReference
    MissingSemicolonAfterCharacterReference
    NoncharacterCharacterReference
    NullCharacterReference
    SurrogateCharacterReference
    UnknownNamedCharacterReference
    CdataInHtmlContent
    ControlCharacterInInputStream
    EofInCdata
    EofInScriptHtmlCommentLikeText
    NoncharacterInInputStream
    SurrogateInInputStream
    } derive(Eq,
    Debug
    )

    WHATWG HTML5 Parse Errors (49 types per specification)

    ParseErrorCode::equal

    ParseErrorCode::not_equal

    fn ParseErrorCode::not_equal(x : ParseErrorCode, y : ParseErrorCode) -> Bool

    ParseErrorCode::output

    fn ParseErrorCode::output(self : ParseErrorCode, logger : &Logger) -> Unit

    ParseErrorCode::to_string

    fn ParseErrorCode::to_string(self : ParseErrorCode) -> String

    QuirksMode

    pub(all) enum QuirksMode {
    NoQuirks
    Quirks
    LimitedQuirks
    } derive(Eq,
    Debug
    )

    Document quirks mode (WHATWG 3.1.4)
    impl Show for QuirksMode

    QuirksMode::equal

    fn QuirksMode::equal(QuirksMode, QuirksMode) -> Bool

    QuirksMode::not_equal

    fn QuirksMode::not_equal(x : QuirksMode, y : QuirksMode) -> Bool

    QuirksMode::output

    fn QuirksMode::output(self : QuirksMode, logger : &Logger) -> Unit

    QuirksMode::to_string

    fn QuirksMode::to_string(self : QuirksMode) -> String

    SourcePosition

    pub struct SourcePosition {
    line : Int
    column : Int
    offset : Int
    } derive(Eq,
    Debug
    )

    Source position for error reporting

    SourcePosition::equal

    SourcePosition::not_equal

    fn SourcePosition::not_equal(x : SourcePosition, y : SourcePosition) -> Bool

    SourcePosition::output

    fn SourcePosition::output(self : SourcePosition, logger : &Logger) -> Unit

    SourcePosition::to_string

    fn SourcePosition::to_string(self : SourcePosition) -> String

    StackEntry

    type StackEntry

    Entry in the stack of open elements

    State

    WHATWG tokenizer states
    impl Show for State

    State::equal

    fn State::equal(State, State) -> Bool

    State::not_equal

    fn State::not_equal(x : State, y : State) -> Bool

    State::output

    fn State::output(self : State, logger : &Logger) -> Unit

    State::to_repr

    State::to_string

    fn State::to_string(self : State) -> String

    Token

    pub(all) enum Token {
    DOCTYPE(name~ : String?, public_id~ : String?, system_id~ : String?, force_quirks~ : Bool)
    StartTag(name~ : String, attrs~ : Array[Attribute], self_closing~ : Bool)
    EndTag(name~ : String)
    Character(Char)
    Comment(String)
    ProcessingInstruction(target~ : String, data~ : String)
    EOF
    } derive(Eq,
    Debug
    )

    HTML5 Token types per WHATWG spec
    impl Show for Token

    Token::equal

    fn Token::equal(Token, Token) -> Bool

    Token::not_equal

    fn Token::not_equal(x : Token, y : Token) -> Bool

    Token::output

    fn Token::output(self : Token, logger : &Logger) -> Unit

    Token::to_repr

    Token::to_string

    fn Token::to_string(self : Token) -> String

    Tokenizer

    pub struct Tokenizer {
    input : Array[Char]
    pos : Int
    line : Int
    column : Int
    last_pos : Int
    last_line : Int
    last_column : Int
    saw_eof : Bool
    input_error_reported : Array[Bool]
    state : State
    return_state : State
    errors : Array[ParseError]
    current_tag_name : StringBuilder
    current_tag_is_end : Bool
    current_tag_self_closing : Bool
    current_attrs : Array[Attribute]
    current_attr_name : StringBuilder
    current_attr_value : StringBuilder
    current_attr_duplicate : Bool
    current_comment : StringBuilder
    current_pi_target : StringBuilder
    current_pi_data : StringBuilder
    current_doctype_name : StringBuilder
    current_doctype_public_id : StringBuilder
    current_doctype_system_id : StringBuilder
    current_doctype_force_quirks : Bool
    current_doctype_public_id_set : Bool
    current_doctype_system_id_set : Bool
    char_ref_code : Int
    temp_buffer : StringBuilder
    last_start_tag_name : String
    pending_tokens : Array[Token]
    in_foreign_content : Bool
    }

    HTML5 Tokenizer per WHATWG Living Standard

    Tokenizer::get_errors

    fn Tokenizer::get_errors(self : Tokenizer) -> Array[ParseError]

    Get all parse errors

    Tokenizer::get_position

    fn Tokenizer::get_position(self : Tokenizer) -> SourcePosition

    Get current source position

    Tokenizer::new

    fn Tokenizer::new(input : String) -> Tokenizer

    Create a tokenizer from a string

    Tokenizer::next_token

    fn Tokenizer::next_token(self : Tokenizer) -> Token

    Read the next token

    Tokenizer::switch_to_plaintext

    fn Tokenizer::switch_to_plaintext(self : Tokenizer) -> Unit

    Switch tokenizer to PLAINTEXT mode (for )

    Tokenizer::switch_to_rawtext

    fn Tokenizer::switch_to_rawtext(self : Tokenizer) -> Unit

    Switch tokenizer to RAWTEXT mode (for , , etc.)

    Tokenizer::switch_to_rcdata

    fn Tokenizer::switch_to_rcdata(self : Tokenizer) -> Unit

    Switch tokenizer to RCDATA mode (for , )

    Tokenizer::switch_to_script_data

    fn Tokenizer::switch_to_script_data(self : Tokenizer) -> Unit

    Switch tokenizer to Script Data mode (for )

    TreeBuilder

    pub struct TreeBuilder {
    tokenizer : Tokenizer
    document : Document
    open_elements : Array[StackEntry]
    active_formatting : Array[FormattingEntry]
    mode : InsertionMode
    original_mode : InsertionMode
    template_modes : Array[InsertionMode]
    head_element : Int
    form_element : Int
    scripting : Bool
    frameset_ok : Bool
    foster_parenting : Bool
    pending_table_chars : Array[Char]
    skip_next_newline : Bool
    errors : Array[ParseError]
    }

    The HTML tree builder (WHATWG 13.2.6)

    TreeBuilder::new

    fn TreeBuilder::new(html : String) -> TreeBuilder

    Create a new tree builder for parsing HTML

    TreeBuilder::new_with_options

    fn TreeBuilder::new_with_options(html : String, scripting~ : Bool) -> TreeBuilder

    Create a new tree builder with options

    TreeBuilder::parse

    fn TreeBuilder::parse(self : TreeBuilder) -> Document

    Parse the document and return it

    NO_NODE

    let NO_NODE : Int

    Node index for O(1) parent/sibling access (using Int directly) Sentinel value NO_NODE = -1 indicates "no node"

    is_formatting_element

    fn is_formatting_element(name : String) -> Bool

    Check if a tag name is a formatting element (adoption agency applies)

    lookup_entity

    fn lookup_entity(name : String) -> Array[Int]?

    Lookup a named character reference (without the leading &) Returns array of codepoints if found

    parse

    fn parse(html : String) -> Document

    Parse an HTML string and return the document

    parse_with_errors

    fn parse_with_errors(html : String) -> (Document, Array[ParseError])

    Parse an HTML string and return the document with errors

    parse_with_scripting

    fn parse_with_scripting(html : String) -> Document

    Parse an HTML string with scripting enabled

    tokenize

    fn tokenize(input : String) -> (Array[Token], Array[ParseError])

    Tokenize entire input and return all tokens

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io