File tree Expand file tree Collapse file tree 1 file changed +37
-1
lines changed Expand file tree Collapse file tree 1 file changed +37
-1
lines changed Original file line number Diff line number Diff line change 1
1
fn main ( ) -> Result < ( ) , markdown:: message:: Message > {
2
+ // Turn on debugging.
3
+ // You can show it with `RUST_LOG=debug cargo run --features log --example lib`
4
+ env_logger:: init ( ) ;
5
+
6
+ // Safely turn (untrusted?) markdown into HTML.
7
+ println ! ( "{:?}" , markdown:: to_html( "## Hello, *world*!" ) ) ;
8
+
9
+ // Turn trusted markdown into HTML.
10
+ println ! (
11
+ "{:?}" ,
12
+ markdown:: to_html_with_options(
13
+ "<div style=\" color: goldenrod\" >\n \n # Hi, *Saturn*! 🪐\n \n </div>" ,
14
+ & markdown:: Options {
15
+ compile: markdown:: CompileOptions {
16
+ allow_dangerous_html: true ,
17
+ allow_dangerous_protocol: true ,
18
+ ..markdown:: CompileOptions :: default ( )
19
+ } ,
20
+ ..markdown:: Options :: default ( )
21
+ }
22
+ )
23
+ ) ;
24
+
25
+ // Support GFM extensions.
26
+ println ! (
27
+ "{}" ,
28
+ markdown:: to_html_with_options(
29
+ "* [x] contact ~Mercury~Venus at [email protected] !" ,
30
+ & markdown:: Options :: gfm( )
31
+ ) ?
32
+ ) ;
33
+
34
+ // Access syntax tree and support MDX extensions:
2
35
println ! (
3
36
"{:?}" ,
4
- markdown:: to_mdast( "# Hi *Earth*!" , & markdown:: ParseOptions :: default ( ) ) ?
37
+ markdown:: to_mdast(
38
+ "# <HelloMessage />, {username}!" ,
39
+ & markdown:: ParseOptions :: mdx( )
40
+ ) ?
5
41
) ;
6
42
7
43
Ok ( ( ) )
You can’t perform that action at this time.
0 commit comments