aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-09-26 16:12:25 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-09-26 16:12:25 +0200
commita0c84c505d733be2e987a333a34244c1befb56cb (patch)
tree0545a747b6f2f627a71bd31949ad622bbc56c176 /examples
parent9cb9e37c33173c16cbafd345f43e43b5a550537d (diff)
downloadmarkdown-rs-a0c84c505d733be2e987a333a34244c1befb56cb.tar.gz
markdown-rs-a0c84c505d733be2e987a333a34244c1befb56cb.tar.bz2
markdown-rs-a0c84c505d733be2e987a333a34244c1befb56cb.zip
Add support for compiling to mdast
See: <https://github.com/syntax-tree/mdast>.
Diffstat (limited to 'examples')
-rw-r--r--examples/lib.rs25
1 files changed, 4 insertions, 21 deletions
diff --git a/examples/lib.rs b/examples/lib.rs
index 98089de..ed108d2 100644
--- a/examples/lib.rs
+++ b/examples/lib.rs
@@ -1,5 +1,5 @@
extern crate micromark;
-use micromark::{micromark, micromark_with_options, Constructs, Options};
+use micromark::{micromark, micromark_to_mdast, micromark_with_options, Constructs, Options};
fn main() -> Result<(), String> {
// Turn on debugging.
@@ -35,30 +35,13 @@ fn main() -> Result<(), String> {
)?
);
- // Support MDX extensions.
- // Note: mdx compiles to nothing, handle it yourself.
+ // Access syntax tree and support MDX extensions:
println!(
- "{}",
- micromark_with_options(
+ "{:?}",
+ micromark_to_mdast(
"# <HelloMessage />, {username}!",
&Options {
constructs: Constructs::mdx(),
- gfm_tagfilter: true,
- ..Options::default()
- }
- )?
- );
-
- // Support other extensions that are not in CommonMark.
- println!(
- "{:?}",
- micromark_with_options(
- "---\ntitle: Neptune\n---\nSome stuff on the moons of Neptune.",
- &Options {
- constructs: Constructs {
- frontmatter: true,
- ..Constructs::default()
- },
..Options::default()
}
)?