{"id":16616878,"url":"https://github.com/sebastienrousseau/html-generator","last_synced_at":"2025-04-22T22:44:27.737Z","repository":{"id":257813883,"uuid":"869093806","full_name":"sebastienrousseau/html-generator","owner":"sebastienrousseau","description":"A Rust-based HTML generation and optimization library.","archived":false,"fork":false,"pushed_at":"2025-04-07T23:22:11.000Z","size":1825,"stargazers_count":4,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-15T05:55:58.663Z","etag":null,"topics":["frontmatter","frontmatter-extraction","html","html-generation","html-generator","seo","seo-optimization","table-of-contents-generator"],"latest_commit_sha":null,"homepage":"http://doc.html-generator.co/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sebastienrousseau.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/funding.yml","license":"LICENSE-APACHE","code_of_conduct":".github/CODE-OF-CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.md","dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"sebastienrousseau","custom":"https://paypal.me/wwdseb"}},"created_at":"2024-10-07T17:52:17.000Z","updated_at":"2025-04-13T20:39:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"3d20b0e9-3478-47ae-843d-d740b0814b75","html_url":"https://github.com/sebastienrousseau/html-generator","commit_stats":null,"previous_names":["sebastienrousseau/html-generator"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebastienrousseau%2Fhtml-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebastienrousseau%2Fhtml-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebastienrousseau%2Fhtml-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebastienrousseau%2Fhtml-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sebastienrousseau","download_url":"https://codeload.github.com/sebastienrousseau/html-generator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250337847,"owners_count":21414099,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["frontmatter","frontmatter-extraction","html","html-generation","html-generator","seo","seo-optimization","table-of-contents-generator"],"created_at":"2024-10-12T02:14:30.518Z","updated_at":"2025-04-22T22:44:27.730Z","avatar_url":"https://github.com/sebastienrousseau.png","language":"Rust","funding_links":["https://github.com/sponsors/sebastienrousseau","https://paypal.me/wwdseb"],"categories":[],"sub_categories":[],"readme":"\u003c!-- markdownlint-disable MD033 MD041 --\u003e\n\u003cimg src=\"https://kura.pro/html-generator/images/logos/html-generator.svg\"\nalt=\"HTML Generator logo\" height=\"66\" align=\"right\" /\u003e\n\u003c!-- markdownlint-enable MD033 MD041 --\u003e\n\n# HTML Generator (html-generator)\n\nA high-performance Rust library that transforms Markdown into semantically rich, accessible HTML with WCAG 2.1 compliance.\n\n\u003c!-- markdownlint-disable MD033 MD041 --\u003e\n\u003ccenter\u003e\n\u003c!-- markdownlint-enable MD033 MD041 --\u003e\n\n[![Made With Love][made-with-rust]][08] [![Crates.io][crates-badge]][03] [![lib.rs][libs-badge]][01] [![Docs.rs][docs-badge]][04] [![Codecov][codecov-badge]][06] [![Build Status][build-badge]][07] [![GitHub][github-badge]][09]\n\n• [Website][00] • [Documentation][04] • [Report Bug][02] • [Request Feature][02] • [Contributing Guidelines][05]\n\n\u003c!-- markdownlint-disable MD033 MD041 --\u003e\n\u003c/center\u003e\n\u003c!-- markdownlint-enable MD033 MD041 --\u003e\n\n## Quick Links\n\n- [HTML Generator (html-generator)](#html-generator-html-generator)\n  - [Quick Links](#quick-links)\n  - [Overview](#overview)\n  - [Key Features](#key-features)\n    - [Markdown Conversion](#markdown-conversion)\n    - [Accessibility and Semantic Markup](#accessibility-and-semantic-markup)\n    - [Performance Optimizations](#performance-optimizations)\n    - [Advanced Configuration](#advanced-configuration)\n  - [Installation](#installation)\n  - [Basic Usage](#basic-usage)\n  - [Advanced Usage Configuration](#advanced-usage-configuration)\n  - [Processing Methods](#processing-methods)\n    - [Synchronous Processing](#synchronous-processing)\n    - [Asynchronous Processing](#asynchronous-processing)\n  - [Error Handling](#error-handling)\n  - [Examples](#examples)\n    - [ARIA Elements \\\u0026 Accessibility](#aria-elements--accessibility)\n    - [Custom Markdown Styling](#custom-markdown-styling)\n    - [Bringing It All Together](#bringing-it-all-together)\n  - [Performance Characteristics](#performance-characteristics)\n  - [Platform Support](#platform-support)\n    - [Continuous Integration](#continuous-integration)\n  - [Conversion Error Handling](#conversion-error-handling)\n  - [Running Examples](#running-examples)\n  - [Contributing](#contributing)\n  - [Licensing](#licensing)\n  - [Acknowledgements](#acknowledgements)\n\n## Overview\n\nHTML Generator is a high-performance Rust library for transforming Markdown into semantically rich, accessible HTML.\n\n## Key Features\n\n### Markdown Conversion\n\n- **Core Processing**:\n  - Standard Markdown to HTML transformation\n  - Configurable parsing with `ComrakOptions`\n  - Front matter extraction support\n  - Basic syntax highlighting via `syntect`\n  - Inline HTML preservation\n\n### Accessibility and Semantic Markup\n\n- **ARIA and Accessibility Features**:\n  - Automated ARIA attribute generation for:\n    - Buttons\n    - Form elements\n    - Navigation structures\n    - Interactive components\n  - WCAG 2.1 validation checks\n  - Semantic HTML structure preservation\n  - Automatic role inference for HTML elements\n\n### Performance Optimizations\n\n- **Efficient Processing**:\n  - O(n) time complexity parsing\n  - Constant memory overhead for small documents\n  - Synchronous and asynchronous HTML generation methods\n  - Minimal runtime overhead\n  - Optional HTML minification\n\n### Advanced Configuration\n\n- **Flexible Transformation**:\n  - Language-specific rendering\n  - Configurable syntax highlighting\n  - Custom block processing\n  - Emoji handling (limited)\n  - SEO metadata generation\n\n## Installation\n\nAdd to your `Cargo.toml`:\n\n```toml\n[dependencies]\nhtml-generator = \"0.0.3\"\n```\n\n## Basic Usage\n\n```rust\nuse html_generator::{generate_html, HtmlConfig};\nuse std::error::Error;\n\nfn main() -\u003e Result\u003c(), Box\u003cdyn Error\u003e\u003e {\n    let markdown = \"# Welcome\\n\\nThis is **HTML Generator**!\";\n    let config = HtmlConfig::default();\n    let html = generate_html(markdown, \u0026config)?;\n    println!(\"{}\", html);\n    Ok(())\n}\n```\n\n## Advanced Usage Configuration\n\n```rust\nuse html_generator::HtmlConfig;\nuse html_generator::error::HtmlError;\n\nfn main() -\u003e Result\u003c(), HtmlError\u003e {\n    let config = HtmlConfig::builder()\n        .with_language(\"en-GB\")\n        .with_syntax_highlighting(true, Some(\"monokai\".to_string()))\n        .build()?;\n\n    println!(\"Built config: {:?}\", config);\n    Ok(())\n}\n```\n\n## Processing Methods\n\n### Synchronous Processing\n\n```rust\nuse html_generator::{generate_html, HtmlConfig};\nuse std::error::Error;\n\nfn main() -\u003e Result\u003c(), Box\u003cdyn Error\u003e\u003e {\n    let markdown = \"# Hello from synchronous processing\";\n    let config = HtmlConfig::default();\n    let html = generate_html(markdown, \u0026config)?;\n    println!(\"{}\", html);\n    Ok(())\n}\n```\n\n### Asynchronous Processing\n\n```rust\n# use html_generator::performance::async_generate_html;\n# use std::error::Error;\n#\n# // We hide the async main to avoid doc-test errors about `.await`.\n# // The code inside demonstrates how you'd normally use `async_generate_html`.\n# async fn async_main_example() -\u003e Result\u003c(), Box\u003cdyn Error\u003e\u003e {\n    let markdown = \"# Async Processing\\n\\nThis is **HTML Generator**!\";\n    let html = async_generate_html(markdown).await?;\n    println!(\"{}\", html);\n    Ok(())\n# }\n```\n\n## Error Handling\n\n```rust\nuse html_generator::{generate_html, HtmlConfig};\nuse html_generator::error::HtmlError;\n\nfn handle_conversion_error(markdown: \u0026str) -\u003e Result\u003c(), HtmlError\u003e {\n    let config = HtmlConfig::default();\n    match generate_html(markdown, \u0026config) {\n        Ok(html) =\u003e println!(\"Conversion successful: {}\", html),\n        Err(HtmlError::InvalidInput(msg)) =\u003e {\n            eprintln!(\"Invalid input: {}\", msg);\n        },\n        Err(HtmlError::InputTooLarge(size)) =\u003e {\n            eprintln!(\"Input too large: {} bytes\", size);\n        },\n        Err(e) =\u003e eprintln!(\"Unexpected error: {}\", e),\n    }\n    Ok(())\n}\n```\n\n## Examples\n\nHTML Generator provides many advanced capabilities for accessibility, ARIA attributes, and custom Markdown styling. Below is a summary of what you can explore. For more detailed code, see the `src/examples/` directory in this repository.\n\n### ARIA Elements \u0026 Accessibility\n\nAdd ARIA attributes to common HTML elements (buttons, forms, tables, and more) to ensure accessibility compliance. The library automatically infers roles and labels for screen readers.\n\n**Example Snippet** _(from `aria_elements_example.rs`)_:\n\n```rust\nuse html_generator::accessibility::add_aria_attributes;\nuse html_generator::error::HtmlError;\n\nfn main() -\u003e Result\u003c(), HtmlError\u003e {\n    // Basic HTML snippet for a button\n    let html_button = \"\u003cbutton\u003eClick me\u003c/button\u003e\";\n\n    // Enhance with ARIA attributes\n    let enhanced_button =\n        add_aria_attributes(html_button, None).map_err(|e| {\n            // Convert from an accessibility::Error to an HtmlError\n            HtmlError::InvalidInput(e.to_string())\n        })?;\n    println!(\"Original:  {}\", html_button);\n    println!(\"Enhanced:  {}\", enhanced_button);\n\n    Ok(())\n}\n```\n\n**Run the full ARIA demo**:\n\n```bash\ncargo run --example aria\n```\n\nThis will print out multiple examples showcasing enhancements for buttons, forms, navigation elements, tables, live regions, and nested components.\n\n### Custom Markdown Styling\n\nDemonstrate transforming extended Markdown features such as:\n\n- **Custom blocks** (e.g., `:::note`, `:::warning`)\n- **Inline `.class=\"...\"` directives** for images or elements\n- **Syntax highlighting** for fenced code blocks\n- **Blockquotes with optional citation**  \n\n…and much more.\n\n**Example Snippet** _(from `style_example.rs`)_:\n\n```rust\nuse html_generator::error::HtmlError;\nuse html_generator::generator::markdown_to_html_with_extensions;\n\nfn main() -\u003e Result\u003c(), HtmlError\u003e {\n    let markdown = r\":::note\nCustom note block with a specific style\n:::\";\n\n    match markdown_to_html_with_extensions(markdown) {\n        Ok(html) =\u003e println!(\"Converted:\\n{}\", html),\n        Err(e) =\u003e println!(\"Error: {}\", e),\n    }\n    Ok(())\n}\n```\n\n**Run the full style demo**:\n\n```bash\ncargo run --example style\n```\n\nThis will print out multiple styled examples (custom blocks, images, tables, bullet lists, code blocks, etc.) and show how they render as HTML.\n\n### Bringing It All Together\n\nIf you’d like to combine accessibility features and custom Markdown styling, you can configure your [`HtmlConfig`](#advanced-configuration) to enable:\n\n1. **Syntax highlighting**\n2. **ARIA attribute generation**\n3. **Custom block parsing**\n4. **Emoji support**\n\n…thereby providing a powerful, end-to-end Markdown-to-HTML transformation pipeline suitable for high-performance, semantically rich, and user-friendly content.\n\n## Performance Characteristics\n\n| Document Scale | Processing Time | Memory Utilization |\n|---------------|----------------|-------------------|\n| Small (\u003c1KB)  | ~0.1ms         | Constant O(1)     |\n| Medium (10KB) | ~1ms           | Linear O(n)       |\n| Large (100KB) | ~10ms          | Linear O(n)       |\n\n## Platform Support\n\n| Platform      | Status     | Rust Version | Notes                     |\n|--------------|------------|--------------|---------------------------|\n| Linux        | ✅ Fully   | 1.56+        | Comprehensive support     |\n| macOS        | ✅ Fully   | 1.56+        | Native performance        |\n| Windows      | ✅ Fully   | 1.56+        | Complete compatibility    |\n| WebAssembly  | ⚠️ Partial | 1.56+        | Limited feature support   |\n\n### Continuous Integration\n\nWe use GitHub Actions for comprehensive testing:\n\n- Cross-platform compatibility checks\n- Extensive test coverage\n\n[View CI Workflow](https://github.com/sebastienrousseau/html-generator/actions)\n\n## Conversion Error Handling\n\n```rust\n# use html_generator::{generate_html, HtmlConfig};\n# use html_generator::error::HtmlError;\n#\nfn handle_conversion_error(markdown: \u0026str) -\u003e Result\u003c(), HtmlError\u003e {\n    // We'll define a config for this snippet:\n    let config = HtmlConfig::default();\n    match generate_html(markdown, \u0026config) {\n        Ok(html) =\u003e println!(\"Conversion successful\"),\n        Err(HtmlError::InvalidInput(msg)) =\u003e {\n            eprintln!(\"Invalid input: {}\", msg);\n        },\n        Err(HtmlError::InputTooLarge(size)) =\u003e {\n            eprintln!(\"Input too large: {} bytes\", size);\n        },\n        Err(HtmlError::Io(io_error)) =\u003e {\n            eprintln!(\"I/O error occurred: {}\", io_error);\n        },\n        // If your crate doesn't actually have a `Markdown` variant, remove this block\n        // Err(HtmlError::Markdown(markdown_error)) =\u003e {\n        //     eprintln!(\"Markdown processing error: {}\", markdown_error);\n        // },\n        Err(e) =\u003e eprintln!(\"Unexpected error: {}\", e),\n    }\n    Ok(())\n}\n```\n\n## Running Examples\n\n```bash\n# Basic example\ncargo run --example basic\n\n# Accessibility demo\ncargo run --example aria\n\n# Performance benchmark\ncargo run --example performance\n```\n\n## Contributing\n\nWe welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for details on:\n\n- Reporting issues\n- Suggesting features\n- Submitting pull requests\n\n## Licensing\n\nDual-licensed: Apache 2.0 \u0026 MIT\n\n## Acknowledgements\n\nSpecial thanks to the Rust community and open-source contributors.\n\n[00]: https://html-generator.co\n[01]: https://lib.rs/crates/html-generator\n[02]: https://github.com/sebastienrousseau/html-generator/issues\n[03]: https://crates.io/crates/html-generator\n[04]: https://docs.rs/html-generator\n[05]: https://github.com/sebastienrousseau/html-generator/blob/main/CONTRIBUTING.md\n[06]: https://codecov.io/gh/sebastienrousseau/html-generator\n[07]: https://github.com/sebastienrousseau/html-generator/actions?query=branch%3Amain\n[08]: https://www.rust-lang.org/\n[09]: https://github.com/sebastienrousseau/html-generator\n\n[build-badge]: https://img.shields.io/github/actions/workflow/status/sebastienrousseau/html-generator/release.yml?branch=main\u0026style=for-the-badge\u0026logo=github\n[codecov-badge]: https://img.shields.io/codecov/c/github/sebastienrousseau/html-generator?style=for-the-badge\u0026token=Q9KJ6XXL67\u0026logo=codecov\n[crates-badge]: https://img.shields.io/crates/v/html-generator.svg?style=for-the-badge\u0026color=fc8d62\u0026logo=rust\n[docs-badge]: https://img.shields.io/badge/docs.rs-html--generator-66c2a5?style=for-the-badge\u0026labelColor=555555\u0026logo=docs.rs\n[github-badge]: https://img.shields.io/badge/github-sebastienrousseau/html--generator-8da0cb?style=for-the-badge\u0026labelColor=555555\u0026logo=github\n[libs-badge]: https://img.shields.io/badge/lib.rs-v0.0.3-orange.svg?style=for-the-badge\n[made-with-rust]: https://img.shields.io/badge/rust-f04041?style=for-the-badge\u0026labelColor=c0282d\u0026logo=rust\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebastienrousseau%2Fhtml-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsebastienrousseau%2Fhtml-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebastienrousseau%2Fhtml-generator/lists"}