diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-10-06 15:57:55 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-10-06 15:57:55 +0200 |
commit | cd5bb2d16c6b28332b0b6077b27b2b90a8051896 (patch) | |
tree | 848ebc6200b80d2dfdcd67bf0bb245eea06bb24f /readme.md | |
parent | 6e80e03bb6d6af47aba2b339f160e4895ab5afba (diff) | |
download | markdown-rs-cd5bb2d16c6b28332b0b6077b27b2b90a8051896.tar.gz markdown-rs-cd5bb2d16c6b28332b0b6077b27b2b90a8051896.tar.bz2 markdown-rs-cd5bb2d16c6b28332b0b6077b27b2b90a8051896.zip |
Refactor to split parse from compile options
Diffstat (limited to 'readme.md')
-rw-r--r-- | readme.md | 30 |
1 files changed, 25 insertions, 5 deletions
@@ -92,17 +92,14 @@ Extensions (in this case GFM): ```rs extern crate micromark; -use micromark::{micromark_with_options, Constructs, Options}; +use micromark::{micromark_with_options, Options}; fn main() -> Result<(), String> { println!( "{}", micromark_with_options( "* [x] contact@example.com ~~strikethrough~~", - &Options { - constructs: Constructs::gfm(), - ..Options::default() - } + &Options::gfm() )? ); @@ -122,6 +119,29 @@ Yields: </ul> ``` +Syntax tree: + +```rs +extern crate micromark; +use micromark::{micromark_to_mdast, ParseOptions}; + +fn main() -> Result<(), String> { + println!( + "{:?}", + micromark_to_mdast("# Hey, *you*!", &ParseOptions::default())? + ); + + Ok(()) +} +``` + +Yields: + +```text +Root { children: [Heading { children: [Text { value: "Hey, ", position: Some(1:3-1:8 (2-7)) }, Emphasis { children: [Text { value: "you", position: Some(1:9-1:12 (8-11)) }], position: Some(1:8-1:13 (7-12)) }, Text { value: "!", position: Some(1:13-1:14 (12-13)) }], position: Some(1:1-1:14 (0-13)), depth: 1 }], position: Some(1:1-1:14 (0-13)) } + +``` + ## API `micromark` exposes |