(Ovid) Re: Pretty Perl display in HTML?
by Ovid (Cardinal) on Aug 10, 2000 at 22:18 UTC
|
I believe what you are looking for is Code2HTML. I answer because you ask. But be forewarned: if you use this, you will get a quick -- vote from myself and other monks. Despite the -- votes, I will often still try to respond to the post.
Intrepid has been known to use this and I routinely vote him down when he uses it (and when he places banner ads in his posts!!!).
It's not that I object horribly to "prettifying" your code, but it's a bit of a distraction and sometimes makes the code illegible with some of the Perlmonks themes.
Cheers,
Ovid | [reply] |
Re: Pretty Perl display in HTML?
by ZZamboni (Curate) on Aug 10, 2000 at 22:20 UTC
|
I saw someone post colorized code here some time ago (it may
not be the same case that nuance mentions because it was at
least a month ago). I asked around,
and it seems it was done using vim. In gvim, select "Syntax->Convert to HTML".
There is of course a :command for doing it, but I can' remember it
offhand.
There was also a similar thread in Formatting perl code for the web,
which contains some other pointers.
I agree with nuance that such colorized code should not be
posted here, at least because it will not look good under all
the color themes available. But I like it otherwise.
--ZZamboni
| [reply] |
Re: Pretty Perl display in HTML?
by tiny (Beadle) on Aug 10, 2000 at 22:47 UTC
|
Take a look at Enscript. Normally it is used for outputting Postscript to printers, but it can also be used to output pretty-printed Perl in HTML. Use the following command:
enscript --pretty-print=perl -G --language=html --color -p- file.pl
Note: don't forget -p-, otherwise you will send your output to the printer.
| [reply] [d/l] |
Re: Pretty Perl display in HTML?
by jeorgen (Pilgrim) on Aug 10, 2000 at 22:31 UTC
|
There is a perl script that does this. It's called "code2html". (There are actually two programs that are called code2html, but only one does perl. They are almost at the same version number 0.8.11 and 0.9.) A perl one-liner for Windows was presented a couple of weeks ago here by Intrepid.
Here is a code fragment that has been run through it:
$report = new Webworks::Log::Report;
$report->print_form;
print qq§ Jumping to good place in file\n§;
$report->html_header(qq§<HTML>
<HEAD>
<TITLE>- A log report-</TITLE>
</HEAD>
<body>
§
);
So you can see some errors it does too.
/jeorgen | [reply] |
Re: Pretty Perl display in HTML?
by jjhorner (Hermit) on Aug 10, 2000 at 22:24 UTC
|
I looked up Intrepid's colorized code (OS.pl) to see what
everyone was talking about. YUCK! How hideous!
Please don't post that here. If you do, you'll get a
quick -- from me with a message saying "YUCK!".
J. J. Horner
Linux, Perl, Apache, Stronghold, Unix
jhorner@knoxlug.org http://www.knoxlug.org/
| [reply] |
|
J.J. is right, this isn't the place to post colorized HTML
code; Perlmonks are specialized geeks some of whom spend
(apparently) inordinate amounts of time and effort on
(fetishistically ?) customizing their Perlmonks experience
with unpredicatable themes. Therefore they won't get out of
it what you wanted them to. However, in another context, it
isn't a bad idea at all. It makes the code more interesting
to look at for that 99.93867% of the rest of humanity
(people who don't code Perl) who might stumble across your site,
and i find that for me it makes syntax stand out well, allowing
me to spot errors or grasp what is going on with some unfamiliar
code more quickly.
I am happy to have been a guinea pig for the use of colorized code on Perlmonks; now those who come after, like the Monk who posted the top inquiry, will know.
BTW, J.J., I am going to edit my node at OS.pl to include
non-colorized code .. but I'll leave the original up there too so that others can see what this thread was about and what not to post on Perlmonks ;-).
soren Intrepid
| [reply] |
Re: Pretty Perl display in HTML?
by nuance (Hermit) on Aug 10, 2000 at 22:03 UTC
|
Someone used something that did that to his code a couple of days ago. It was universally unpopular, if you find something please don't use it for posting to this site
Thankyou.
Nuance
| [reply] |