Crates.io | mdx-gen |
lib.rs | mdx-gen |
version | 0.0.1 |
source | src |
created_at | 2024-09-30 13:09:09.417145 |
updated_at | 2024-09-30 13:09:09.417145 |
description | A robust Rust library for processing Markdown and converting it to HTML with support for custom blocks, enhanced table formatting, and flexible configuration options. |
homepage | https://mdxgen.com/ |
repository | https://github.com/sebastienrousseau/mdx-gen |
max_upload_size | |
id | 1391693 |
size | 182,187 |
A robust Rust library for processing Markdown into responsive HTML, offering custom blocks, syntax highlighting, and enhanced table formatting for richer content.
• Website • Documentation • Report Bug • Request Feature • Contributing Guidelines
mdx-gen
is a flexible Rust library that converts Markdown into HTML, providing enhanced features like custom block extensions, syntax highlighting, and table formatting.
mdx-gen
uses the high-performance comrak
library for Markdown parsing and offers flexible options for modifying and extending Markdown behavior.
comrak
parser, ensuring fast and accurate rendering of Markdown content.MarkdownOptions
structure that allows developers to enable or disable specific features (e.g., custom blocks, enhanced tables, or syntax highlighting).mdx-gen
offers the following extensions, which can be enabled or disabled individually via MarkdownOptions
:
Add this to your Cargo.toml
:
[dependencies]
mdx-gen = "0.0.1"
Here are some examples of how to use the library:
use mdx_gen::{process_markdown, MarkdownOptions};
let markdown_content = "# Hello, world!\n\nThis is a paragraph.";
let options = MarkdownOptions::new()
.with_enhanced_tables(false);
let html = process_markdown(markdown_content, &options).unwrap();
println!("HTML output: {}", html);
use mdx_gen::{process_markdown, MarkdownOptions};
let markdown_content = r#"
# Example
<div class="note">This is a note.</div>
``rust
fn main() {
println!("Hello, world!");
}
"#;
let options = MarkdownOptions::new()
.with_custom_blocks(true)
.with_syntax_highlighting(true)
.with_enhanced_tables(true)
.with_comrak_options({
let mut opts = comrak::ComrakOptions::default();
opts.extension.table = true;
opts
});
let html = process_markdown(markdown_content, &options).unwrap();
println!("HTML output: {}", html);
For full API documentation, please visit docs.rs/mdx-gen.
To run the examples, clone the repository and use the following command:
cargo run --example example_name
Replace example_name
with the name of the example you want to run.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
The project is dual-licensed under the terms of both the MIT license and the Apache License (Version 2.0).
at your option.
Special thanks to all contributors who have helped build the mdx-gen
library.