Add proper syntax highlighting with Phutil.

This commit is contained in:
epriestley
2011-01-24 17:39:14 -08:00
parent a3df19976f
commit 52126c5479
4 changed files with 149 additions and 7 deletions

View File

@@ -311,8 +311,16 @@ class DifferentialChangesetParser {
$min_length = min(count($this->old), count($this->new));
for ($ii = 0; $ii < $min_length; $ii++) {
if ($this->old[$ii] || $this->new[$ii]) {
$otext = idx($this->old[$ii], 'text', '');
$ntext = idx($this->new[$ii], 'text', '');
if (isset($this->old[$ii]['text'])) {
$otext = $this->old[$ii]['text'];
} else {
$otext = '';
}
if (isset($this->new[$ii]['text'])) {
$ntext = $this->new[$ii]['text'];
} else {
$ntext = '';
}
if ($otext != $ntext && empty($skip_intra[$ii])) {
$this->intra[$ii] = ArcanistDiffUtils::generateIntralineDiff(
$otext,
@@ -560,9 +568,10 @@ class DifferentialChangesetParser {
}
protected function sourceHighlight($data, $corpus) {
// $result = highlight_code($corpus, $this->filetype);
$result = phutil_escape_html($corpus);
$result = $this->highlightEngine->highlightSource(
$this->filetype,
$corpus);
$result_lines = explode("\n", $result);
foreach ($data as $key => $info) {
if (!$info) {
@@ -655,6 +664,8 @@ EOSYNTHETIC;
$range_len = null,
$mask_force = array()) {
$this->highlightEngine = new PhutilDefaultSyntaxHighlighterEngine();
$this->tryCacheStuff();
$changeset_id = $this->changesetID;
@@ -1157,7 +1168,7 @@ EOSYNTHETIC;
$table = null;
if ($contents) {
$table =
'<table class="differential-diff">'.
'<table class="differential-diff remarkup-code">'.
$contents.
'</table>';
}