mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-02 11:42:42 +01:00
b6d745b666
Summary: All classes should extend from some other class. See D13275 for some explanation. Test Plan: `arc unit` Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D13283
31 lines
876 B
PHP
31 lines
876 B
PHP
<?php
|
|
|
|
final class PhabricatorSyntaxHighlighter extends Phobject {
|
|
|
|
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);
|
|
}
|
|
|
|
}
|