automatic syntax highlighting in web pages ?

M

Matthias Pospiech

There are many sites that offer code examples with syntax highlighting. Is
there a way to generate the highlighting with a php or phyton function
automatically ?

How is such a thing done generally ?

Matthias
 
M

Mitja

There are many sites that offer code examples with syntax highlighting.
Is there a way to generate the highlighting with a php or phyton function
automatically ?
For python, there's a module imaginatively called py2html.
http://www.peck.org.uk/p/python/
How is such a thing done generally ?
Scripts, always. You can do it on the fly or with pregenerated html files.
Usually the second version is preferrable, but you're the only one who
knows which is better for your particular situation.
 
H

Hywel Jenkins

What if I dont want to higlight PHP Code ?
for example LaTeX code ?

Well, I'd say you find or write code to do it. There are no doubt
already functions or classes that do several languages out there.
Google is your friend.
 
T

Toby Inkster

Matthias said:
There are many sites that offer code examples with syntax highlighting. Is
there a way to generate the highlighting with a php or phyton function
automatically ?

/usr/bin/enscript is installed on many Linux and Unix servers. Though
it's primarily designed for PostScript output, it can be told to output
HTML instead.

My copy of enscript does syntax highlighting of:

ada
asm
awk
bash
changelog
cpp
csh
c
delphi
diffs
diff
diffu
elisp
fortran_pp
fortran
haskell
html
idl
inf
javascript
java
ksh
m4
mail
makefile
matlab
nroff
objc
outline
pascal
perl
postscript
pyrex
python
rfc
scheme
sh
skill
sql
states
synopsys
tcl
tcsh
tex
vba
verilog
vhdl
vrml
wmlscript
zsh

Other versions may do slightly more/less.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top