pub struct Document { /* private fields */ }Implementations§
Source§impl Document
impl Document
pub fn parse(input: &[u8], format: Format) -> Result<Self, Error>
pub fn parse_str(input: &str, format: Format) -> Result<Self, Error>
Sourcepub fn render_html(&mut self) -> Result<Vec<u8>, Error>
pub fn render_html(&mut self) -> Result<Vec<u8>, Error>
Render the document to HTML. For Djot/Markdown this is the rich rendering path that resolves reference/footnote side tables.
Sourcepub fn serialize(&mut self, format: Format) -> Result<Vec<u8>, Error>
pub fn serialize(&mut self, format: Format) -> Result<Vec<u8>, Error>
Serialize the document to format’s own source syntax: a round-trip
when format matches the document’s own format, cross-format
conversion otherwise (e.g. parse Markdown, serialize as Djot). Returns
Error::UnsupportedFormat when the requested direction has no
serializer (today: converting into XML from another format).
Sourcepub fn ast_json(&mut self) -> Result<Vec<u8>, Error>
pub fn ast_json(&mut self) -> Result<Vec<u8>, Error>
Encode the document’s AST as pretty-printed JSON (the same encoding as
twig convert -o ast).
Sourcepub fn query(&mut self, selector: &str) -> Result<Vec<QueryMatch>, Error>
pub fn query(&mut self, selector: &str) -> Result<Vec<QueryMatch>, Error>
Resolve a CSS-lite selector (e.g. heading[level=2],
link[dest^="http"], code, list > item) against the document,
returning one QueryMatch per matching node in document order. A
malformed selector yields Error::InvalidArgument.
This is the general replacement for scanning code spans by hand: a
verbatim / code_block / raw_inline / raw_block selector recovers
those, and every other node kind is reachable too.