diff --git a/examples/lib.rs b/examples/lib.rs
index 7923782..43a6243 100644
--- a/examples/lib.rs
+++ b/examples/lib.rs
@@ -1,43 +1,7 @@
fn main() -> Result<(), markdown::message::Message> {
- // Turn on debugging.
- // You can show it with `RUST_LOG=debug cargo run --features log --example lib`
- env_logger::init();
-
- // Safely turn (untrusted?) markdown into HTML.
- println!("{:?}", markdown::to_html("## Hello, *world*!"));
-
- // Turn trusted markdown into HTML.
- println!(
- "{:?}",
- markdown::to_html_with_options(
- "
\n\n# Hello, tomato!\n\n
",
- &markdown::Options {
- compile: markdown::CompileOptions {
- allow_dangerous_html: true,
- allow_dangerous_protocol: true,
- ..markdown::CompileOptions::default()
- },
- ..markdown::Options::default()
- }
- )
- );
-
- // Support GFM extensions.
- println!(
- "{}",
- markdown::to_html_with_options(
- "* [x] contact@example.com ~~strikethrough~~",
- &markdown::Options::gfm()
- )?
- );
-
- // Access syntax tree and support MDX extensions:
println!(
"{:?}",
- markdown::to_mdast(
- "# , {username}!",
- &markdown::ParseOptions::mdx()
- )?
+ markdown::to_mdast("# Hi *Earth*!", &markdown::ParseOptions::default())?
);
Ok(())
diff --git a/readme.md b/readme.md
index 88063bb..4ace6b2 100644
--- a/readme.md
+++ b/readme.md
@@ -120,14 +120,14 @@ cargo add markdown@1.0.0-alpha.23
```rs
fn main() {
- println!("{}", markdown::to_html("## Hello, *world*!"));
+ println!("{}", markdown::to_html("## Hi, *Saturn*! 🪐"));
}
```
Yields:
```html
-Hello, world!
+Hi, Saturn! 🪐
```
Extensions (in this case GFM):
@@ -137,7 +137,7 @@ fn main() -> Result<(), markdown::message::Message> {
println!(
"{}",
markdown::to_html_with_options(
- "* [x] contact@example.com ~~strikethrough~~",
+ "* [x] contact ~Mercury~Venus at hi@venus.com!",
&markdown::Options::gfm()
)?
);
@@ -152,8 +152,7 @@ Yields:
```
@@ -164,7 +163,7 @@ Syntax tree ([mdast][]):
fn main() -> Result<(), markdown::message::Message> {
println!(
"{:?}",
- markdown::to_mdast("# Hey, *you*!", &markdown::ParseOptions::default())?
+ markdown::to_mdast("# Hi *Earth*!", &markdown::ParseOptions::default())?
);
Ok(())
@@ -174,7 +173,7 @@ fn main() -> Result<(), markdown::message::Message> {
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)) }
+Root { children: [Heading { children: [Text { value: "Hi ", position: Some(1:3-1:6 (2-5)) }, Emphasis { children: [Text { value: "Earth", position: Some(1:7-1:12 (6-11)) }], position: Some(1:6-1:13 (5-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
diff --git a/src/lib.rs b/src/lib.rs
index ebf4afd..c1e5d6a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -84,7 +84,7 @@ use alloc::string::String;
/// ```
/// use markdown::to_html;
///
-/// assert_eq!(to_html("# Hello, world!"), "Hello, world!
");
+/// assert_eq!(to_html("# Hi Mercury!"), "Hi Mercury!
");
/// ```
pub fn to_html(value: &str) -> String {
to_html_with_options(value, &Options::default()).unwrap()
@@ -107,12 +107,12 @@ pub fn to_html(value: &str) -> String {
/// # fn main() -> Result<(), markdown::message::Message> {
///
/// // Use GFM:
-/// let result = to_html_with_options("~hi~hello!", &Options::gfm())?;
+/// let result = to_html_with_options("~Venus~Mars!", &Options::gfm())?;
///
-/// assert_eq!(result, "hihello!
");
+/// assert_eq!(result, "VenusMars!
");
///
/// // Live dangerously / trust the author:
-/// let result = to_html_with_options("\n\n# Hello, world!\n\n
", &Options {
+/// let result = to_html_with_options("\n\n# Hi Jupiter!\n\n
", &Options {
/// compile: CompileOptions {
/// allow_dangerous_html: true,
/// allow_dangerous_protocol: true,
@@ -121,7 +121,7 @@ pub fn to_html(value: &str) -> String {
/// ..Options::default()
/// })?;
///
-/// assert_eq!(result, "\n
Hello, world!
\n");
+/// assert_eq!(result, "\n
Hi Jupiter!
\n");
/// # Ok(())
/// # }
/// ```
@@ -150,10 +150,10 @@ pub fn to_html_with_options(value: &str, options: &Options) -> Result Result<(), markdown::message::Message> {
///
-/// let tree = to_mdast("# Hey, *you*!", &ParseOptions::default())?;
+/// let tree = to_mdast("# Hi *Earth*!", &ParseOptions::default())?;
///
/// println!("{:?}", tree);
-/// // => 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)) }
+/// // => Root { children: [Heading { children: [Text { value: "Hi ", position: Some(1:3-1:6 (2-5)) }, Emphasis { children: [Text { value: "Earth", position: Some(1:7-1:12 (6-11)) }], position: Some(1:6-1:13 (5-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)) }
/// # Ok(())
/// # }
/// ```