Home | Site Map
Sunlight

CPPtoHTML

Introduction

There is often a requirement to put properly formatted source code on the Web - be it C, C++ or C# - and this code is normally hand-formatted, resulting in errors, with no real capacity for formatting the code.

CPPtoHTML solves this problem by automatically converting source code into HTML, using CSS stylesheets so that the result can be easily and quickly integrated into any Web site. Simply drag any C, C++ or C# file onto the program and it will create a HTML version. It can also generate Programmer's Heaven bulletin board codes for code formatting with an option switch.

This new version (23/9/2001) handles C# source files.

Code Notes

You can download a Zip file of the source code, including a Microsoft Visual C++ project you can use to build the project.

Things to note:

  • It keeps a sorted list of highlighted keywords, which is then processed by the standard C binary search function. This makes the keyword search very fast. If you change the keyword list, be sure to keep it sorted.
  • Under Windows, it illustrates reading parameters (the stylesheet) from the registry. Notice that it reads LOCAL_MACHINE first, and then CURRENT_USER, so that per-user settings override per-machine settings.
  • It accepts an option switch (-s stylesheet) which allows you to set the stylesheet.
  • It accepts an option switch (-p) to select Programmer's Heaven codes ([code], [colour], [size]).

Download

Source code (5k): CPPtoHTMLSrc.zip

Program (52k): CPPtoHTML.exe