Language Autodetectioassembly-x86fortherlanghaskellrviewtexttyposcriptapplescriptcobolgnuplotjavascriptobjectrexxjavassharpsquidconfribsqrlotostexinfocsharpaspphpcvs-commitnsis2vhdldprologjavaccactionscripthtmlrpmspecembperlantlrmysqlxslschemetwikimyghtyperlpascalnetrexxjhtmlpl-sqllispassembly-m68kcchillmaplegroovyawkbcelpythonsdl_prhexpowerdynamofreemarkermakefileidlinterlisiconrtfprogressrelax-ng-compacttclpatchsmi-mibjspnqcxmlmqscinno-setupphp_inlineaspect-jredcodegenericrhtmllatexmailverilogcplusplustestmlfactorpspassembly-mcs51batchjclhtaccesssasvelocityjmkgettextada95apacheconfapdlbibtexpl1pikebiniliterate-haskelloccamuscriptcoldfusionpovraydoxygensmalltalkobjective-cassembly-r2000cssbbjsplusdjangoptlslateshellscriptpyrexqrestluapop11foxprorebolswigassembly-parrotzptsvn-commiti4glrubyinformomnimarkshtmltexcatalogtplsgmltsqlcilxqfortrandssslrdlilypondassembly-macro32moinmodula3pvwaveeiffelvbscriptpropspostscriptText <?php /** * This is a demonstration file. * I proudly present: How to use jEph * */ $jephDir = ...; #$jephDir = ...; // Include JEph require($jephDir.'/Jeph.php'); // Set pathnames for jEph // "true" means to interprete the pathnames as relative to jEph's directory Jeph::setModeFilesPath('./modes/', true); Jeph::setCacheFilesPath('./cache/', true); echo('<?xml version="1.0" encoding="ISO-8859-1"?>'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <title>jEPh demo</title> <style type="text/css"> label { display: block; background: #eee; margin-top: 10px; width: 75%; } input, textarea { display: block; width: 75%; } textarea { height: 400px; } code { font-size: 12px; padding-left: 20px; border-left: 2px solid #eee; display: block; width: 90%; max-height: 300px; overflow: auto; } <?php echo Jeph::getDefaultCss() ?> </style> <link rel="stylesheet" href="style.css" type="text/css" media="screen, projection" /> </head> <body> <h1>jEph Demo</h1> <?php if(!isset($_POST['text'])) { ?> <h2>Highlight text</h2> <form method="post" action="demo.php"> <p> <label for="language">Language</label> <select name="language" id="language"> <option selected="selected">Autodetect</option> <?php $modes = new DirectoryIterator($jephDir.'/modes/'); foreach($modes as $file) { if(!$file->isFile()) { continue; } echo('<option>'.preg_replace('/\.[^.]+$/', '', $file).'</option>'.PHP_EOL); } ?> </select> <label for="text">Text</label> <textarea cols="70" rows="15" name="text" id="text"><?php echo(htmlspecialchars( preg_replace('/\$jephDir\s+=.+$/m', '$'.'jephDir = ...;', file_get_contents(__FILE__)))); ?></textarea> <input type="submit"/> </p> </form> <?php } else { // Create a new highlighter if($_POST['language'] == 'Autodetect') { $myJeph = new Jeph(); } else { $myJeph = new Jeph($_POST['language']); } // Highlight the text from the formular echo('<h2>Highlighted text</h2>'); echo('<p>Click here to <a href="demo.php">go back</a></p><div>'); $time = microtime(true); try { echo($myJeph->parse2html(stripslashes($_POST['text']))); } catch(Exception $except) { echo('<p><strong>Error</strong>: '.$except->getMessage().'</p>'); } $time = round(microtime(true) - $time, 2); echo('</div><p>Highlighted as language '.$myJeph->getLanguage().' in '.$time.' seconds.</p>'); echo('</div><p>Click here to <a href="demo.php">go back</a></p>'); } ?> </body> </html>