Skip to content

org-myjtools/doc2html

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Doc to HTML

Maven Central Quality Gate Status Coverage Bugs Vulnerabilities Maintainability Rating

A Java library to transform documentation files (like Markdown) into HTML with optional features such as syntax highlighting, Mermaid diagrams, GitHub emojis, and Font Awesome icons. In addition, it can extract the document title and generate a table of contents.

This library is intended to be used in conjunction with j2html for building HTML documents in Java.

Requirements

  • Java 21 or higher

Installation

Add the following dependency to your pom.xml:

<dependency>
    <groupId>org.myjtools</groupId>
    <artifactId>doc2html</artifactId>
    <version>1.0.0</version>
</dependency>

Usage

import org.myjtools.doc2html.*;
import java.io.FileReader;

// Create a Markdown generator
HtmlGenerator generator = new MarkdownHtmlGenerator();

// Enable optional features
generator.setFeature(Feature.SYNTAX_HIGHLIGHTING, true);
generator.setFeature(Feature.MERMAID_DIAGRAMS, true);
generator.setFeature(Feature.GITHUB_EMOJIS, true);

// Transform a Markdown file to HtmlDoc
try (FileReader reader = new FileReader("README.md")) {
    HtmlDoc doc = generator.transform(reader);

    // Get the generated components
    HeadTag head = doc.head();           // Contains CSS/JS resources
    MainTag main = doc.main();           // Contains the HTML content
    NavTag toc = doc.tableOfContents(1, 3); // Table of contents (h1-h3)
    String title = doc.titleText();      // Extracted title
}

Features

Feature Description
SYNTAX_HIGHLIGHTING Code block syntax highlighting using Prism.js
MERMAID_DIAGRAMS Render Mermaid diagrams
GITHUB_EMOJIS Convert GitHub emoji codes (e.g., :smile:) to Unicode
FONT_AWESOME_ICONS Include Font Awesome CSS

License

MIT License

About

Documentation (Markdown) to HTML

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages