Expand description
§marxml
Fast markdown + XML query, mutation, validation, and serialization. Rust core for the marxml ecosystem. See https://github.com/thebytefarm/marxml.
The crate exposes:
parse/parse_fragment/parse_owned— build aMarkdowndocument from a source string.Selector— CSS-subset selectors compiled once, reused against many documents.Markdown::update/Markdown::replace_content/Markdown::replace_in— string-returning mutation helpers.Schema+validate— declarative validation.Markdown::to_xml/Markdown::to_json+SerializeOpts— render the parsed tree back out.
let doc = marxml::parse("<task id=\"1\">hello</task>")?;
assert_eq!(doc.root_count(), 1);Re-exports§
pub use schema::AttrConstraint;pub use schema::AttrKind;pub use schema::Schema;pub use schema::SchemaBuilder;pub use schema::SchemaError;pub use schema::TagBuilder;
Modules§
- schema
- Declarative schema for validating parsed documents.
Structs§
- Element
Ref - A cheap reference to a parsed element, borrowing from the owning
Markdowndocument. - Markdown
- A parsed markdown + embedded XML document.
- Mutation
Report - Outcome of a successful mutation. Reports both the rewritten document and any accounting useful for diagnostics.
- Selector
- A compiled CSS-subset selector.
- Serialize
Opts - Options for
Markdown::to_xml. - Source
Position - A position in the source document.
- Source
Span - A half-open span of source positions:
[start, end). - Validation
Report - Outcome of
validate.
Enums§
- Mutate
Error - Errors returned by the fallible mutation variants.
- Parse
Error - Errors returned from
crate::parseandcrate::parse_fragment. - Selector
Error - An error returned when a selector string fails to parse.
- Validation
Error - One problem found during validation. Every variant carries a 1-based
linenumber and the offendingtagfor diagnostic output.
Constants§
- MAX_
DEPTH - Maximum depth of element nesting accepted by the parser.
- MAX_
INPUT_ BYTES - Maximum byte length of input accepted by the parser.
- VERSION
- Crate version exposed for downstream diagnostics.
Functions§
- escape_
attr - Escape
valuefor use inside a double-quoted XML attribute literal. - escape_
text - Escape
valuefor use as XML text content. - is_
valid_ name truewhennameis a syntactically valid XML name as recognized by the rest of the crate (non-empty, starts with a name-start byte, every subsequent byte is a name-char).- parse
- Parse a full markdown+XML document.
- parse_
fragment - Parse a fragment.
- parse_
owned - Parse a document, moving in the owned source string instead of cloning
it. Use this when you already own a
Stringand want to avoid the allocation thatparsewould do internally. - validate
- Validate every element in
docwhose tag is named inschema.