Expand description
§HTML Generator (html-generator)
A Rust-based HTML generation and optimization library.
• Website • Documentation • Report Bug • Request Feature • Contributing Guidelines
§Overview
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.
§Features
- Markdown to HTML Conversion: Convert Markdown content to HTML with support for custom extensions.
- Front Matter Extraction: Extract and process front matter from Markdown content.
- Advanced Header Processing: Automatically generate id and class attributes for headers.
- Table of Contents Generation: Create a table of contents from HTML content.
- SEO Optimization: Generate meta tags and structured data (JSON-LD) for improved search engine visibility.
- Accessibility Enhancements: Add ARIA attributes and validate against WCAG guidelines.
- Performance Optimization: Minify HTML output and support asynchronous generation for large sites.
- Flexible Configuration: Customize the HTML generation process through a comprehensive set of options.
§Installation
Add this to your Cargo.toml
:
[dependencies]
html-generator = "0.0.1"
§Usage
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(())
}
§Documentation
For full API documentation, please visit docs.rs/html-generator.
§Examples
To run the examples, clone the repository and use the following command:
cargo run --example example_name
§Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
§License
This project is licensed under either of
at your option.
§Acknowledgements
Special thanks to all contributors who have helped build the html-generator
library.
Re-exports§
pub use accessibility::add_aria_attributes;
pub use accessibility::validate_wcag;
pub use generator::generate_html;
pub use performance::async_generate_html;
pub use performance::minify_html;
pub use seo::generate_meta_tags;
pub use seo::generate_structured_data;
pub use utils::extract_front_matter;
pub use utils::format_header_with_id_class;
Modules§
- The
accessibility
module contains functions for improving accessibility. Accessibility-related functionality for HTML processing. - The
error
module contains error types for HTML generation. Error types for HTML generation and processing. - The
generator
module contains functions for generating HTML content. HTML generation module for converting Markdown to HTML. - The
performance
module contains functions for optimizing performance. Performance-related functionality for HTML processing. - The
seo
module contains functions for optimizing SEO. SEO-related functionality for HTML processing. - The
utils
module contains utility functions. Utility functions for HTML and Markdown processing.
Structs§
- Configuration options for HTML generation
Enums§
- Error type for HTML generation
Type Aliases§
- Result type for HTML generation