for version 0.8.8
-p [file [alternate_outfile]]
--modes.
This input is treated case-insensitive.
If not given, some heuristics will be used to determine the file language.
--fallback plain
--modes.
--no_header is given too, this has no meaning.
If no file is given, code2html reads from STDIN and writes to STDOUT. If just one file is given it replaces this file with the output.
To use this feature, just insert a like like this into your html file:
<!-- code2html add [options] <file> -->
the syntax highlighted file will be inserted at this position enclosed in <pre> tags.
All options that can be given on the command line like --linenumbers etc. work. --help and --version
etc. work too however it is not very intelligent to use them :). --content_type is ignored.
You may also write the program's source code directly in the html file with the following syntax:
<!-- code2html add [options]
<your program source code here>
-->
It is usually a good idea to at least give the -l option to specify the language.
This is a very new feature, so if you have problems or questions, please let me know. An example can be found at my homepage: http://www.cosy.sbg.ac.at/~ppalfrad
--content_type is switched on automatically and the output always goes to STDOUT.
The following parameters/options are accepted:
if not given, some heuristics are used to find out the language.
@CGI_ENCODING
in the script to match your program locations.
If no_encoding is defined and true code2html does not try to encode the output.
Note that by default it is possbile for your users to read all the files the httpd can read (if you don't run a cgi- wrapper or something like this . You may disallow file reading via cgi with setting FILES_DISALLOWED_IN_CGI to 1 at the top of the script.
The input selector REDIRECT_URL needs a special explaination. The file name is formed from the two enviroment variables DOCUMENT_ROOT and REDIRECET_URL.
If you want apache to automatically call code2html for all program source code files you may do this by adding these two lines to your srm.conf:
AddHandler text/code .c .cc .cpp .pas .h .p Action text/code /cgi-bin/code2html?input_selector=REDIRECT_URL&foo=
or something similar to this. In the AddHandle line you can choose which extensions to pass through code2html.
WARNING: Do not add .pl to this line and name this script ``code2html.pl''. This will result in a loop.
Replace /cgi-bin/code2html with the virtual location under which the file can be accessed. Note the ``foo='' part. Apache appends the URL of the file to display at the end of the action part. We do not need this since we use the environment variable ``REDIRECT_URL'' however we do not want to get the url addes to the input_selector string. Therefore we append the ``&foo='' part.
Tnx to Kevin Burton
> It is more powerfull if you use it in an Apache
> <Directory> tag
>
> <Directory /source>
>
> #with your Action tag here... this way you can
> #still have regular .java files on your server.
>
> </Directory>
code2html.pl -l perl code2html.pl code2html.html
to convert the script into a html file.
-L or --language_file if any
The file structure must be valid perl code.
The global variable %LANGUAGE is already defined, so you
should not redeclare it using ``my''.
It is probably the best idea to look at the definition you can see at the bottom of code2html.
If your pattern includes back references like a lot patterns do in perl for example, then you have to use \2 instead of \1, \3 instead of \2 and so on. I really don't like this hack but it is a lot faster. Example:
<<([^\n]*).*?^\2$
In this example the perl << stuff is matched, i.e. everything from a << until a line that consists of exactly the same string as behind the << was. The \2 references the matched chars in the parentenses.
If you ever write languages files yourself, I'ld be happy if you could send be them, so I put them on my homepage with full credits of course. Before you do so you might also have a look at my site to check wheter someone has written the file for your language already.
-l command line parameter.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ``Software''), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.