mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 05:20:56 +01:00
Update Phabricator for split syntax highlighting API
Summary: I'll clean some of this stuff up in a followup too, but update the callers to use the new explicit filename-based API. Test Plan: Looked at paste, Diffusion and Differential. Reviewed By: tuomaspelkonen Reviewers: tuomaspelkonen, codeblock, jungejason, aran CC: aran, tuomaspelkonen Differential Revision: 600
This commit is contained in:
parent
f123abcc5a
commit
70cd8b1b34
3 changed files with 21 additions and 14 deletions
|
@ -27,7 +27,6 @@ class DifferentialChangesetParser {
|
|||
protected $parsedHunk = false;
|
||||
|
||||
protected $filename = null;
|
||||
protected $filetype = null;
|
||||
protected $missingOld = array();
|
||||
protected $missingNew = array();
|
||||
|
||||
|
@ -161,10 +160,7 @@ class DifferentialChangesetParser {
|
|||
|
||||
public function setFilename($filename) {
|
||||
$this->filename = $filename;
|
||||
if (strpos($filename, '.', 1) !== false) {
|
||||
$parts = explode('.', $filename);
|
||||
$this->filetype = end($parts);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setHandles(array $handles) {
|
||||
|
@ -723,7 +719,7 @@ class DifferentialChangesetParser {
|
|||
|
||||
protected function getHighlightFuture($corpus) {
|
||||
return $this->highlightEngine->getHighlightFuture(
|
||||
$this->filetype,
|
||||
$this->highlightEngine->getLanguageFromFilename($this->filename),
|
||||
$corpus);
|
||||
}
|
||||
|
||||
|
|
|
@ -179,13 +179,16 @@ class DiffusionBrowseFileController extends DiffusionController {
|
|||
|
||||
list($text_list, $rev_list, $blame_dict) = $file_query->getBlameData();
|
||||
|
||||
$highlightEngine = new PhutilDefaultSyntaxHighlighterEngine();
|
||||
$highlightEngine->setConfig(
|
||||
$highlight_engine = new PhutilDefaultSyntaxHighlighterEngine();
|
||||
$highlight_engine->setConfig(
|
||||
'pygments.enabled',
|
||||
PhabricatorEnv::getEnvConfig('pygments.enabled'));
|
||||
|
||||
$text_list = explode("\n", $highlightEngine->highlightSource($path,
|
||||
implode("\n", $text_list)));
|
||||
$text_list = explode(
|
||||
"\n",
|
||||
$highlight_engine->highlightSource(
|
||||
$highlight_engine->getLanguageFromFilename($path),
|
||||
implode("\n", $text_list)));
|
||||
|
||||
$rows = $this->buildDisplayRows($text_list, $rev_list, $blame_dict,
|
||||
$needs_blame, $drequest, $file_query, $selected);
|
||||
|
|
|
@ -89,14 +89,22 @@ class PhabricatorPasteViewController extends PhabricatorPasteController {
|
|||
require_celerity_resource('diffusion-source-css');
|
||||
require_celerity_resource('syntax-highlighting-css');
|
||||
|
||||
$highlightEngine = new PhutilDefaultSyntaxHighlighterEngine();
|
||||
$highlightEngine->setConfig(
|
||||
$highlight_engine = new PhutilDefaultSyntaxHighlighterEngine();
|
||||
$highlight_engine->setConfig(
|
||||
'pygments.enabled',
|
||||
PhabricatorEnv::getEnvConfig('pygments.enabled'));
|
||||
|
||||
|
||||
$language = $paste->getLanguage();
|
||||
if (empty($language)) {
|
||||
$language = $highlight_engine->getLanguageFromFilename(
|
||||
$paste->getTitle());
|
||||
}
|
||||
|
||||
$text_list = explode(
|
||||
"\n", $highlightEngine->highlightSource(
|
||||
nonempty($paste->getLanguage(), $paste->getTitle()),
|
||||
"\n",
|
||||
$highlight_engine->highlightSource(
|
||||
$language,
|
||||
$file->loadFileData()));
|
||||
|
||||
$rows = $this->buildDisplayRows($text_list);
|
||||
|
|
Loading…
Reference in a new issue