Skip to content

freedomwatchers/code2html

 
 

Repository files navigation

CodeToHTML

This is a simple tool to generate code syntax highlighting in HTML format.

Features

  • Syntax Highlighting: Supports C/C++ syntax highlighting.
    • Keywords (Blue)
    • Comments (Green)
    • string/char literals (Gray)
  • HTML Generation: Converts source code to HTML documents.
  • Cross-Platform: Compiles on Linux and Windows.
  • Wildcard Support: Built-in wildcard expansion for Windows.

C++ Support Matrix

The following table details the level of C++ support provided by this tool.

Feature Category Fully Supported Not Supported (Rendered as plain text)
C++ Standard C++98, C++03, C++11 C++14, C++17, C++20
Keywords All keywords from C++11 (e.g., constexpr, nullptr, decltype, final, override) Post-C++11 keywords
Types int, char, float, double, void, bool, char16_t, char32_t, auto, etc. Post-C++11 types
OO / Memory class, struct, union, new, delete, this, public, private, friend, virtual -
Preprocessor #include, #define, #ifdef, #ifndef, #endif, #pragma, #import, #else -
Modern C++ Lambdas, static_assert, thread_local (Keywords) co_await, module, etc.

C++ Feature Documentation

Below are links to documentation for features discussed above.

Supported Features

Unsupported Features

Development Onboard

Dependencies

  • C++ Compiler (g++, clang++, or MSVC)
  • Standard C++ Libraries

fast-track for Ubuntu/Debian

sudo apt-get install build-essential

Build Instructions

To build the project on Linux/Unix (full-featured version):

g++ parser.cpp cppparse.cpp -o code2html

Note

parsefiles.cpp contains a legacy standalone version with limited keyword support. For full C++11 highlighting, always build with parser.cpp and cppparse.cpp.

Usage

Run the tool by providing the source file(s) as arguments:

./code2html parsefiles.cpp

This will generate parsefiles.cpp.html.

Testing Battery

A more complex testing battery is available to run code2html against entire Git repositories. This battery clones a repository, processes all C++ files, and generates a summary report.

Running the Testing Battery

Provide the Git repository URL as an argument to the run_test_battery.sh script:

./run_test_battery.sh <repository_url>

Example:

./run_test_battery.sh https://github.com/danmar/cppcheck.git

Outputs

  • Cloned Repo: The repository is cloned into a local directory.
  • HTML Files: All generated HTML files are stored in a code2html_output directory within the cloned repository, preserving the original directory structure.
  • Summary Report: A summary_report.md is generated in the code2html_output directory, containing metrics, stats, and details of any failed files.

Notes

  • This project contains some legacy code for wildcard expansion from the Samba project.

Feature Coverage & Reports

About

C++-based syntax highlighter

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 51.9%
  • HTML 42.2%
  • Shell 5.9%