read()) !== false) { if ($e[0] !== "." && $e !== "default.css" && strpos($e, ".css") !== false) { $styles[] = $e; } } sort($styles); use Highlight\Highlighter; $hl = new Highlighter(); $hl->setAutodetectLanguages($hl->listLanguages()); $tableRows = ""; $failed = array(); foreach ($hl->listLanguages() as $name) { $sn = $name; $snippet = file_get_contents("../test/detect/{$sn}/default.txt"); $r = $hl->highlightAuto($snippet); $passed = ($r->language === $name); $res = "
{$r->language}" . " ({$r->relevance})
"; if (isset($r->secondBest)) { $res .= "{$r->secondBest->language}" . " ({$r->secondBest->relevance})"; } $tableRows .= "{$name}{$res}
{$r->value}
"; if (!$passed) { $failed[] = $name; } } if (count($failed)) { $testResult = "

Failed tests: " . implode(", ", $failed); } else { $testResult = "

All tests passed"; } $testResult .= "

Highlighting took " . (microtime(true) - $start) . " seconds

"; $d->close(); ?> highlight.js test

This is a demo/test page showing all languages supported by highlight.php. Most snippets do not contain working code :-).

Styles

Automatically detected languages