nel-all
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nel] cpp to html in php :)


From: Vincent Caron
Subject: Re: [Nel] cpp to html in php :)
Date: 01 Mar 2002 17:47:37 +0100

I use a little wrapper around 'enscript', which is a good multi-language
and multi-media beautifier :

function snippet($file, $lang)
{
  $output = `enscript -q -E$lang -Whtml --color -o - $file`;
  $start = strpos ($output, '<PRE>');
  $end = strpos ($output, '</PRE>') + strlen('</PRE>');
  return substr ($output, $start, $end-$start);
}

You just invoke 'echo snippet("/path/to/test.cpp", "cpp")'. It can be
modified to support 'inline code' (ie. passed from a string in the PHP
code) though ...




reply via email to

[Prev in Thread] Current Thread [Next in Thread]