mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-27 17:22:42 +01:00
8756d82cf6
Summary: I'm pretty sure that `@group` annotations are useless now... see D9855. Also fixed various other minor issues. Test Plan: Eye-ball it. Reviewers: #blessed_reviewers, epriestley, chad Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley, Korvin, hach-que Differential Revision: https://secure.phabricator.com/D9859
31 lines
859 B
PHP
31 lines
859 B
PHP
<?php
|
|
|
|
final class PhabricatorSyntaxHighlighter {
|
|
|
|
public static function newEngine() {
|
|
$engine = PhabricatorEnv::newObjectFromConfig('syntax-highlighter.engine');
|
|
|
|
$config = array(
|
|
'pygments.enabled' => PhabricatorEnv::getEnvConfig('pygments.enabled'),
|
|
'filename.map' => PhabricatorEnv::getEnvConfig('syntax.filemap'),
|
|
);
|
|
|
|
foreach ($config as $key => $value) {
|
|
$engine->setConfig($key, $value);
|
|
}
|
|
|
|
return $engine;
|
|
}
|
|
|
|
public static function highlightWithFilename($filename, $source) {
|
|
$engine = self::newEngine();
|
|
$language = $engine->getLanguageFromFilename($filename);
|
|
return $engine->highlightSource($language, $source);
|
|
}
|
|
|
|
public static function highlightWithLanguage($language, $source) {
|
|
$engine = self::newEngine();
|
|
return $engine->highlightSource($language, $source);
|
|
}
|
|
|
|
}
|