Crates.io | pegmd |
lib.rs | pegmd |
version | 0.2.3 |
source | src |
created_at | 2023-07-12 01:23:48.440869 |
updated_at | 2023-08-03 21:20:13.095571 |
description | A PEG based markdown parser for creating an Abstract Syntax Tree |
homepage | |
repository | https://github.com/mdd36/pegmd |
max_upload_size | |
id | 914221 |
size | 62,662 |
Parses a Markdown document that follows CommonMark v0.30 to an abstract syntax tree by defining its parsing expression
grammar (PEG) with pest. The crate also optionally provides a transformer to emit the AST as HTML if the html
feature included.
The main function exported from the crate, ast::parse_document
, accepts a &str
and on success returns a Node
with the same lifetime as the input.
From there, you can traverse the tree by creating a struct that implements the traversal::Vistor
trait and providing it to the Node::traverse
method.
If the html
feature is enabled, the crate provides the html::HTMLTransformer
struct that implements the Visitor
trait to create a well-formatted HTML output.
pest
lacks support for streaming, this crate also can't read a document from a stream.While the end goal for the parser is to support the entire CommonMark spec, it currently doesn't support:
All of these are a WIP and will be added to the parser.