Crates.io | struckdown |
lib.rs | struckdown |
version | 0.1.0 |
source | src |
created_at | 2020-12-24 14:58:28.048205 |
updated_at | 2020-12-24 14:58:28.048205 |
description | A structured markdown / commonmark library for Rust |
homepage | https://github.com/mitsuhiko/struckdown |
repository | https://github.com/mitsuhiko/struckdown |
max_upload_size | |
id | 326907 |
size | 192,327 |
struckdown is an experimental markdown/commonmark processing pipeline library inspired by Python's docutils and Sphinx. The idea is to support custom roles and directives for markdown similar to how how reStructuredText works and to provide an abstraction that can be processed by standardized tools without having to be aware of how MarkDown works.
A markdown document is parsed into an event stream which can then be modified by event processors including external tools. Because the event stream can be serialized to JSON it's easy to manipulate.
use struckdown::pipeline::Pipeline;
use struckdown::processors::{AutoAnchors, Syntect};
use struckdown::html::to_html;
// create a default pipeline
let mut pipeline = Pipeline::default();
// add a processor for anchors and syntax highlighting.
pipeline.add_processor(AutoAnchors::default());
pipeline.add_processor(Syntect::default());
// parse and process into a final event stream.
let stream = pipeline.process(r#"
# Hello World
```python
print("Hello World!");
```"#);
// render to html
let html = to_html(stream, &Default::default());