#markdown-html #html #seo #web-dev

html-generator

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.

2 releases

0.0.2 Dec 1, 2024
0.0.1 Oct 7, 2024

#1107 in Web programming

Download history 162/week @ 2024-10-03 76/week @ 2024-10-10 23/week @ 2024-10-17 76/week @ 2024-10-24 59/week @ 2024-10-31 164/week @ 2024-11-07 38/week @ 2024-11-14 39/week @ 2024-11-21 195/week @ 2024-11-28 117/week @ 2024-12-05 34/week @ 2024-12-12

388 downloads per month
Used in 4 crates (2 directly)

MIT/Apache

255KB
5K SLoC

HTML Generator logo

HTML Generator (html-generator)

A comprehensive Rust library for transforming Markdown into optimised, accessible HTML.

Made With Love Crates.io lib.rs Docs.rs Codecov Build Status GitHub

WebsiteDocumentationReport BugRequest FeatureContributing Guidelines

Overview 🎯

The html-generator library simplifies the process of transforming Markdown into SEO-optimised, accessible HTML. This library provides tools for processing front matter, generating semantic headers, validating accessibility, and optimising performance for modern web applications.

Features ✨

Markdown to HTML Conversion

  • Standard and Custom Extensions: Supports GFM and extensible custom syntax.
  • Front Matter Parsing: Processes YAML/TOML/JSON front matter seamlessly.
  • Header Customisation: Generates semantic headers with custom IDs and classes.

SEO and Accessibility

  • SEO Utilities: Automatically generates meta tags and JSON-LD structured data.
  • Accessibility Enhancements: Validates against WCAG standards and supports ARIA attributes.
  • Semantic HTML: Ensures well-structured, readable markup.

Performance Optimisations

  • Asynchronous Processing: Handles large documents efficiently with async support.
  • HTML Minification: Reduces file sizes while maintaining functionality.
  • Lightweight: Optimised for minimal memory usage and fast execution.

Developer-Friendly

  • Configurable API: Extensively configurable options for flexible use cases.
  • Detailed Errors: Comprehensive error types for easier debugging.
  • Rich Documentation: Includes examples and detailed usage guides.

Installation 🚀

Add the following to your Cargo.toml:

[dependencies]
html-generator = "0.0.2"

Usage 💻

Basic Example

use html_generator::{generate_html, HtmlConfig};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = HtmlConfig::default();

    let markdown = "# Welcome to HTML Generator

This library makes HTML creation effortless.";
    let html = generate_html(markdown, &config)?;

    println!("Generated HTML:
{}", html);
    Ok(())
}

Advanced Example

use html_generator::{
    accessibility::validate_wcag,
    seo::{generate_meta_tags, generate_structured_data},
    HtmlConfig,
};

async fn advanced_example() -> Result<String, Box<dyn std::error::Error>> {
    let config = HtmlConfig::builder()
        .with_language("en-GB")
        .with_syntax_highlighting(true, Some("dracula".to_string()))
        .build()?;

    let markdown = "# Advanced Example

Features include syntax highlighting and WCAG validation.";
    let html = generate_html(markdown, &config)?;

    validate_wcag(&html, &config, None)?;
    let meta_tags = generate_meta_tags(&html)?;
    let structured_data = generate_structured_data(&html, None)?;

    Ok(format!("{}
{}
{}", meta_tags, structured_data, html))
}

Examples 💡

Run examples from the repository:

git clone https://github.com/sebastienrousseau/html-generator.git
cd html-generator
cargo run --example basic

Documentation 📚

Contributing 🤝

We welcome contributions of all kinds! Please read our Contributing Guidelines for instructions on:

  • Reporting issues
  • Requesting features
  • Submitting code

License 📜

This project is licensed under either of the following at your choice:

Acknowledgements 🙏

Heartfelt thanks to all contributors who have supported the development of html-generator.

Dependencies

~25–38MB
~594K SLoC