Crates.io | html-generator |
lib.rs | html-generator |
version | 0.0.1 |
source | src |
created_at | 2024-10-07 19:38:27.789421 |
updated_at | 2024-10-07 19:38:27.789421 |
description | A robust Rust library designed for transforming Markdown into SEO-optimized, accessible HTML. Featuring front matter extraction, custom header processing, table of contents generation, and performance optimization for web projects of any scale. |
homepage | https://html-generator.co/ |
repository | https://github.com/sebastienrousseau/html-generator |
max_upload_size | |
id | 1400397 |
size | 216,329 |
A Rust-based HTML generation and optimization library.
• Website • Documentation • Report Bug • Request Feature • Contributing Guidelines
The html-generator
is a robust Rust library designed for transforming Markdown into SEO-optimized, accessible HTML. Featuring front matter extraction, custom header processing, table of contents generation, and performance optimization for web projects of any scale.
Add this to your Cargo.toml
:
[dependencies]
html-generator = "0.0.1"
Here's a basic example of how to use html-generator
:
use html_generator::utils::{extract_front_matter, format_header_with_id_class, generate_table_of_contents};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Extract front matter
let content = "---\ntitle: My Page\n---\n# Hello, world!\n\nThis is a test.";
let content_without_front_matter = extract_front_matter(content)?;
println!("Content without front matter:\n{}", content_without_front_matter);
// Format header with ID and class
let header = "<h2>Hello, World!</h2>";
let formatted_header = format_header_with_id_class(header, None, None)?;
println!("Formatted header:\n{}", formatted_header);
// Generate table of contents
let html = "<h1>Title</h1><p>Some content</p><h2>Subtitle</h2><p>More content</p>";
let toc = generate_table_of_contents(html)?;
println!("Table of contents:\n{}", toc);
Ok(())
}
For full API documentation, please visit docs.rs/html-generator.
To run the examples, clone the repository and use the following command:
cargo run --example example_name
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under either of
at your option.
Special thanks to all contributors who have helped build the html-generator
library.