0.1.1 |
|
---|---|
0.1.0 |
|
#9 in #commonmark
120KB
2.5K
SLoC
markdown-fmt
I published this fork by accident. Please find SichangHe on GitHub if you want this crate name 🙏.
lib.rs
:
Easily format Markdown. markdown_fmt supports CommonMark and GitHub Flavored Markdown.
Getting Started
use markdown_fmt::rewrite_markdown;
let markdown = r##" # Getting Started
1. numbered lists
1. are easy!
"##;
let formatted = r##"# Getting Started
1. numbered lists
1. are easy!
"##;
let output = rewrite_markdown(markdown)?;
Using the Builder
The builder gives you more control to configure Markdown formatting.
use markdown_fmt::{rewrite_markdown, rewrite_markdown_with_builder, FormatterBuilder};
let builder = FormatterBuilder::with_code_block_formatter(|info_string, code_block| {
match info_string.to_lowercase().as_str() {
"markdown" => rewrite_markdown(&code_block).unwrap_or(code_block),
_ => code_block
}
});
let markdown = r##" # Using the Builder
+ markdown code block nested in a list
```markdown
A nested markdown snippet!
* unordered lists
are also pretty easy!
- `-` or `+` can also be used as unordered list markers.
```
"##;
let formatted = r##"# Using the Builder
+ markdown code block nested in a list
```markdown
A nested markdown snippet!
* unordered lists
are also pretty easy!
- `-` or `+` can also be used as unordered list markers.
```
"##;
let output = rewrite_markdown_with_builder(markdown, builder)?;
Dependencies
~3–5MB
~80K SLoC