Click on highlight.cpp to get source.
// Return-Path: <hitzm@cs.rpi.edu>
// Received: from vega.cs.rpi.edu by cs.rpi.edu (5.67a/1.4-RPI-CS-Dept)
// id AA04155; Wed, 28 Jun 1995 14:29:59 -0400 (hitzm from vega.cs.rpi.edu)
// Message-Id: <199506281829.AA04155@cs.rpi.edu>
// X-Mailer: exmh version 1.6.1 5/23/95
// To: kaltofen
// Cc: hitzm
// Subject: Re: STL program for index generation
// In-Reply-To: Your message of "Wed, 28 Jun 1995 12:32:25 EDT."
// <9506281632.AA13343@blackbox.cs.rpi.edu>
// Mime-Version: 1.0
// Content-Type: text/plain; charset=us-ascii
// Date: Wed, 28 Jun 1995 14:29:57 -0400
// From: Markus Hitz <hitzm@cs.rpi.edu>
// Status: RO
//
//
// Erich:
//
// the program is attached below. You have to compile it with
// Apogee's "apCC". In order to get the STL files included, you
// can use the following one-line script:
//
// apCC $1 $2 $3 $4 $5 $6 $7 $8 $9 -I/dept/cs/include/stl
//
// (Write it to a file "astl" and chmod it +x). I think the program
// is too crude to be useful for other people right know. It could
// be easily improved by adding some "kill set" which would allow to
// filter out non-keywords like "the", as well as TeX and LaTeX commands.
//
// Markus
//
// --------------------------- C++ program ---------------------------------
//
//
// Generates hightlighted source file (based on M.H.'s index.cpp)
//
// interface: a.out <filename> <lang> [<path prefix>]
// where <lang> is c or cpp
// and the optional path prefix is the relative path to the C++ page
// e.g., ../ from a subdirectory
//
// output: file named "<filename>.html"
//
#include <ctype.h>
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
using namespace std;
int main (int argc, char *argv[])
{
char buf[128];
int c, i=0;
if (argc < 3)
{
cerr << argv[0]
<< ": missing arguments" << endl;
return 1;
}
ifstream text (argv[1], ios::in);
if (!text)
{
cerr << argv[0]
<< ": cannot open "
<< argv[1] << endl;
return 2;
}
strcpy (buf, argv[1]);
strcat (buf, ".html");
ofstream htmlfile (buf, ios::out);
if (!htmlfile)
{
cerr << argv[0]
<< ": cannot open output file" << endl;
return 3;
}
cout << "Making " << buf << endl;
// write header
if(argc >= 4) strcpy(buf,argv[3]); else strcpy(buf,"");
htmlfile << "<html>" << endl;
htmlfile << "<link rel=\"stylesheet\" href=\"" << buf << "../Highlight/styles/default.css\">"
<< endl;
htmlfile << "<script src=\"" << buf << "../Highlight/highlight.pack.js\"></script>"
<< endl;
htmlfile << "<script>hljs.initHighlightingOnLoad();</script>"
<< endl;
htmlfile << "Click on <a href=\""<<argv[1]<<"\">"<<argv[1]<<"</a> to get source."
<< endl;
htmlfile << "<pre><code class=\"" << argv[2] << "\">"; // EK: remove << endl;
// copy code replacing < with <
while ((c = text.get ()) != EOF)
{
if ((char)c == '<') htmlfile << '&' << "lt;";
else if ((char)c == '\n') htmlfile << endl;
else htmlfile << (char) c;
}
// write trailer
htmlfile << "</code></pre>" << endl;
htmlfile << "</html>" << endl;
return 0;
}