sunlight

CPPtoHTML

Introduction

There is often a requirement to put properly formatted source code on the Web - be it C, C+ or Java - 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 Java file onto the program and it will create a HTML version.

This new version can also generate Programmer's Heaven bulletin board codes for code formatting with an option switch.

CPPtoHTML Code Notes

You can view the source code here (formatted with itself): CPPtoHTML.cpp. You can also 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]).

CPPtoHTML Download

Source code (5k): CPPtoHTMLSrc.zip

Program (52k): CPPtoHTML.exe

 

Copyright © David McCabe, 1998 - 2001. All rights reserved.

You will need to download and install the m-math control to display any equations on this Web site. Without this control, you will not see most of the equations. Please do not e-mail me asking why the equations do not display!

[an error occurred while processing this directive]