From cd5bb2d16c6b28332b0b6077b27b2b90a8051896 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Thu, 6 Oct 2022 15:57:55 +0200 Subject: Refactor to split parse from compile options --- examples/lib.rs | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'examples') diff --git a/examples/lib.rs b/examples/lib.rs index ed108d2..d14f399 100644 --- a/examples/lib.rs +++ b/examples/lib.rs @@ -1,5 +1,7 @@ extern crate micromark; -use micromark::{micromark, micromark_to_mdast, micromark_with_options, Constructs, Options}; +use micromark::{ + micromark, micromark_to_mdast, micromark_with_options, CompileOptions, Options, ParseOptions, +}; fn main() -> Result<(), String> { // Turn on debugging. @@ -15,8 +17,11 @@ fn main() -> Result<(), String> { micromark_with_options( "
\n\n# Hello, tomato!\n\n
", &Options { - allow_dangerous_html: true, - allow_dangerous_protocol: true, + compile: CompileOptions { + allow_dangerous_html: true, + allow_dangerous_protocol: true, + ..CompileOptions::default() + }, ..Options::default() } ) @@ -27,24 +32,14 @@ fn main() -> Result<(), String> { "{}", micromark_with_options( "* [x] contact@example.com ~~strikethrough~~", - &Options { - constructs: Constructs::gfm(), - gfm_tagfilter: true, - ..Options::default() - } + &Options::gfm() )? ); // Access syntax tree and support MDX extensions: println!( "{:?}", - micromark_to_mdast( - "# , {username}!", - &Options { - constructs: Constructs::mdx(), - ..Options::default() - } - )? + micromark_to_mdast("# , {username}!", &ParseOptions::mdx())? ); Ok(()) -- cgit