1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 17:22:42 +01:00
phorge-phorge/src/infrastructure/markup/PhabricatorSyntaxHighlighter.php
Joshua Spence 8756d82cf6 Remove @group annotations
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
2014-07-10 08:12:48 +10:00

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);
}
}