README

bobzhang/html_parser/parser does not have a README file

#
FragmentContext

pub(all) struct FragmentContext {
tag_name : String
ns : String?
} derive(Eq,
Debug
)

Context element used when parsing an HTML fragment.

The tag name is normalized to lowercase. ns can be used for foreign content contexts such as SVG or MathML.

#
FragmentContext::new

fn FragmentContext::new(tag_name : StringView, ns? : String) -> FragmentContext

Construct a fragment parsing context.

#
ParsedHtml

Result of parsing HTML.

root is the document or fragment root. errors is populated when collect_errors=true or strict parsing observes an error. encoding is set by byte parsing APIs.

#
ParsedHtml::query

fn ParsedHtml::query(self : ParsedHtml, selector : StringView) -> Array[
Node
]

Return all descendants of the parsed root that match a CSS selector.

#
ParsedHtml::query_one

fn ParsedHtml::query_one(self : ParsedHtml, selector : StringView) ->
Node
?

Return the first descendant of the parsed root that matches a CSS selector.

#
ParsedHtml::to_html

fn ParsedHtml::to_html(self : ParsedHtml, pretty? : Bool, indent_size? : Int, context? :
HtmlContext
, quote? : Char) -> String raise
HtmlError

Serialize the parsed root node back to HTML.

This forwards to to_html on self.root.

#
ParsedHtml::to_markdown

fn ParsedHtml::to_markdown(self : ParsedHtml, html_passthrough? : Bool) -> String raise
HtmlError

Render the parsed document or fragment root as Markdown.

This is equivalent to calling to_markdown on self.root.

#
ParsedHtml::to_text

fn ParsedHtml::to_text(self : ParsedHtml, separator? : String, strip? : Bool, separator_blocks_only? : Bool) -> String

Extract text from the parsed root node.

This forwards to to_text on self.root.

#
parse

fn parse(html : StringView, sanitize? : Bool, collect_errors? : Bool, strict? : Bool, scripting_enabled? : Bool, xml_coercion? : Bool, track_node_locations? : Bool) -> ParsedHtml raise
HtmlError

Parse a full HTML document from a string.

The returned root is a document node with the usual html, head, and body scaffolding. Set sanitize=true to apply the default document sanitizer after parsing, collect_errors=true to keep parse diagnostics, and strict=true to raise @core.HtmlError::StrictMode on the first parse error.

#
parse_bytes

fn parse_bytes(input : BytesView, encoding? : String, sanitize? : Bool, collect_errors? : Bool, strict? : Bool, scripting_enabled? : Bool, xml_coercion? : Bool, track_node_locations? : Bool) -> ParsedHtml raise
HtmlError

Decode and parse an HTML byte stream.

When encoding is absent, BOMs and <meta charset> declarations are sniffed before falling back to Windows-1252. The detected or requested encoding is stored in ParsedHtml.encoding.

#
parse_fragment

fn parse_fragment(html : StringView, context? : FragmentContext, sanitize? : Bool, collect_errors? : Bool, strict? : Bool, scripting_enabled? : Bool, xml_coercion? : Bool, track_node_locations? : Bool) -> ParsedHtml raise
HtmlError

Parse an HTML fragment from a string.

context controls the fragment context element used by the tree builder. Without a context, the fragment is parsed into a generic fragment root. sanitize, collect_errors, strict, scripting_enabled, xml_coercion, and track_node_locations have the same meaning as in parse.

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io