### Run Examples Script
Source: https://github.com/wooorm/markdown-rs/blob/main/readme.md
Bash script to run examples with backtrace and logging enabled. It sets the RUST_BACKTRACE and RUST_LOG environment variables and uses cargo run with the example lib and log feature.
```sh
RUST_BACKTRACE=1 RUST_LOG=trace cargo run --example lib --features log
```
--------------------------------
### Generate Documentation Script
Source: https://github.com/wooorm/markdown-rs/blob/main/readme.md
Bash script to generate documentation using cargo doc. It includes private items, examples, and the entire workspace in the generated documentation.
```sh
cargo doc --document-private-items --examples --workspace
```
--------------------------------
### Installing markdown-rs with Cargo
Source: https://github.com/wooorm/markdown-rs/blob/main/readme.md
This command adds the markdown crate as a dependency to your Rust project using Cargo, the Rust package manager. This allows you to use the markdown parsing functionality in your Rust code.
```sh
cargo add markdown
```
--------------------------------
### Fuzz Testing Script
Source: https://github.com/wooorm/markdown-rs/blob/main/readme.md
Bash script to perform fuzz testing using cargo-fuzz and honggfuzz. It installs the necessary tools and runs the fuzz tests for markdown_libfuzz and markdown_honggfuzz.
```sh
cargo install cargo-fuzz
cargo install honggfuzz
cargo +nightly fuzz run markdown_libfuzz
cargo hfuzz run markdown_honggfuzz
```
--------------------------------
### Debugging Tokenizer Events
Source: https://github.com/wooorm/markdown-rs/blob/main/Untitled.txt
This Rust code snippet iterates through a list of tokenizer events, printing details about each event, including its kind, name, index, and link. It uses indentation to visualize the nesting structure of the events based on 'Enter' and 'Exit' event kinds. The code depends on the `std` crate for printing and the `alloc` crate for using `String`.
```Rust
// ---------------------
// Useful helper:
extern crate std;
use std::println;
use alloc::string::String;
let mut index = 0;
let mut balance = 0;
println!("before: {:?}", tokenizer.events.len());
while index < tokenizer.events.len() {
let event = &tokenizer.events[index];
if event.kind == Kind::Exit {
balance -= 1;
}
let prefix = String::from_utf8(vec![b' '; balance * 2]).unwrap();
println!(
"ev: {}{:?}:{:?} ({:?}): {:?}",
prefix, event.kind, event.name, index, event.link,
);
if event.kind == Kind::Enter {
balance += 1;
}
index += 1;
}
```
--------------------------------
### Markdown Parsing Process
Source: https://github.com/wooorm/markdown-rs/blob/main/readme.md
Visual representation of the markdown parsing process using markdown-rs, showing the flow from markdown input to HTML or mdast output through parsing and compilation stages.
```txt
markdown-rs
+-------------------------------------------------+
| +-------+ +---------+--html- |
| -markdown->+ parse +-events->+ compile + |
| +-------+ +---------+-mdast- |
+-------------------------------------------------+
```
--------------------------------
### Markdown to HTML Output with GFM Extensions
Source: https://github.com/wooorm/markdown-rs/blob/main/readme.md
This is the HTML output generated by the previous Rust code snippet, demonstrating the rendering of GFM extensions such as task lists, strikethrough, and autolinking.
```html
```
--------------------------------
### Basic Markdown to HTML Conversion
Source: https://github.com/wooorm/markdown-rs/blob/main/readme.md
This Rust code snippet demonstrates how to convert a simple markdown string to HTML using the `markdown::to_html` function. It prints the resulting HTML to the console.
```rs
fn main() {
println!("{}", markdown::to_html("## Hi, *Saturn*! 🪐"));
}
```
--------------------------------
### Markdown to Syntax Tree (mdast) Output
Source: https://github.com/wooorm/markdown-rs/blob/main/readme.md
This is the text output generated by the previous Rust code snippet, demonstrating the structure of the mdast (Markdown Abstract Syntax Tree) for the input markdown string.
```text
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)) }
```
--------------------------------
### Lint Code Script
Source: https://github.com/wooorm/markdown-rs/blob/main/readme.md
Bash script to lint the code using cargo fmt and cargo clippy. It checks the formatting and runs clippy to find potential issues across all features, targets, and the workspace.
```sh
cargo fmt --check && cargo clippy --all-features --all-targets --workspace
```
--------------------------------
### Markdown to HTML Conversion with GFM Extensions
Source: https://github.com/wooorm/markdown-rs/blob/main/readme.md
This Rust code snippet demonstrates how to convert a markdown string to HTML using the `markdown::to_html_with_options` function, enabling GFM (GitHub Flavored Markdown) extensions. It showcases features like task lists, strikethrough, and autolinking. The function returns a `Result` to handle potential errors during the conversion.
```rs
fn main() -> Result<(), markdown::message::Message> {
println!(
"{}",
markdown::to_html_with_options(
"* [x] contact ~Mercury~Venus at hi@venus.com!",
&markdown::Options::gfm()
)?
);
Ok(())
}
```
--------------------------------
### Markdown to Syntax Tree (mdast) Conversion
Source: https://github.com/wooorm/markdown-rs/blob/main/readme.md
This Rust code snippet demonstrates how to convert a markdown string to an mdast (Markdown Abstract Syntax Tree) using the `markdown::to_mdast` function. It prints the resulting AST to the console. The function returns a `Result` to handle potential errors during the conversion.
```rs
fn main() -> Result<(), markdown::message::Message> {
println!(
"{:#?}",
markdown::to_mdast("# Hi *Earth*!", &markdown::ParseOptions::default())?
);
Ok(())
}
```
--------------------------------
### Generate Code Script
Source: https://github.com/wooorm/markdown-rs/blob/main/readme.md
Bash script to generate code using cargo run with a specific manifest path. This is used for generating the latest CommonMark tests and Unicode information.
```sh
cargo run --manifest-path generate/Cargo.toml
```
--------------------------------
### Test Code Script
Source: https://github.com/wooorm/markdown-rs/blob/main/readme.md
Bash script to run tests with backtrace enabled. It sets the RUST_BACKTRACE environment variable and uses cargo test across all features and the workspace.
```sh
RUST_BACKTRACE=1 cargo test --all-features --workspace
```
--------------------------------
### Format Code Script
Source: https://github.com/wooorm/markdown-rs/blob/main/readme.md
Bash script to format the code using cargo fmt and cargo fix. It formats the code and fixes any linting issues across all features, targets, and the workspace.
```sh
cargo fmt && cargo fix --all-features --all-targets --workspace
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.