mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 06:42:42 +01:00
Add proper syntax highlighting with Phutil.
This commit is contained in:
parent
a3df19976f
commit
52126c5479
4 changed files with 149 additions and 7 deletions
|
@ -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>';
|
||||
}
|
||||
|
|
|
@ -54,7 +54,8 @@ class PhabricatorStandardPageView extends AphrontPageView {
|
|||
|
||||
protected function getHead() {
|
||||
return
|
||||
'<link rel="stylesheet" type="text/css" href="/rsrc/css/base.css" />';
|
||||
'<link rel="stylesheet" type="text/css" href="/rsrc/css/base.css" />'.
|
||||
'<link rel="stylesheet" type="text/css" href="/rsrc/css/syntax.css" />';
|
||||
}
|
||||
|
||||
public function setGlyph($glyph) {
|
||||
|
|
|
@ -747,3 +747,14 @@ th.aphront-side-nav-navigation a.aphront-side-nav-selected:hover {
|
|||
margin: 0 40px;
|
||||
max-width: 1162px;
|
||||
}
|
||||
|
||||
/************* meta notice ************************************************ */
|
||||
|
||||
.differential-meta-notice {
|
||||
border: 1px solid #ffdd99;
|
||||
background: #ffeeaa;
|
||||
font-family: "Verdana";
|
||||
font-size: 11px;
|
||||
padding: 1em;
|
||||
margin: 0 0 6px 0;
|
||||
}
|
||||
|
|
119
webroot/rsrc/css/syntax.css
Normal file
119
webroot/rsrc/css/syntax.css
Normal file
|
@ -0,0 +1,119 @@
|
|||
.remarkup-code .uu { /* Forbidden Unicode */
|
||||
color: #aa0066;
|
||||
}
|
||||
|
||||
.remarkup-code .over-the-line {
|
||||
color: #aa0066;
|
||||
margin-right: 1px;
|
||||
}
|
||||
|
||||
.remarkup-code td span {
|
||||
padding: 1px 0 3px;
|
||||
}
|
||||
|
||||
|
||||
.remarkup-code .hll {
|
||||
background-color: #ffffcc;
|
||||
}
|
||||
|
||||
.remarkup-code .c, /* Comment */
|
||||
.remarkup-code .cm, /* Comment.Multiline */
|
||||
.remarkup-code .c1, /* Comment.Single */
|
||||
.remarkup-code .cs { /* Comment.Special */
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
.remarkup-code .sd, /* Literal.String.Doc */
|
||||
.remarkup-code .sh { /* Literal.String.Heredoc */
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
.remarkup-code .s, /* Literal.String */
|
||||
.remarkup-code .sb, /* Literal.String.Backtick */
|
||||
.remarkup-code .sc, /* Literal.String.Char */
|
||||
.remarkup-code .s2, /* Literal.String.Double */
|
||||
.remarkup-code .s1, /* Literal.String.Single */
|
||||
.remarkup-code .sx { /* Literal.String.Other */
|
||||
color: #766510;
|
||||
}
|
||||
|
||||
.remarkup-code .sr { /* Literal.String.Regex */
|
||||
color: #BB6688;
|
||||
}
|
||||
|
||||
.remarkup-code .nv, /* Name.Variable */
|
||||
.remarkup-code .vi, /* Name.Variable.Instance */
|
||||
.remarkup-code .vg { /* Name.Variable.Global */
|
||||
color: #001294;
|
||||
}
|
||||
|
||||
.remarkup-code .na { /* Name.Attribute */
|
||||
color: #354BB3;
|
||||
}
|
||||
|
||||
.remarkup-code .kc, /* Keyword.Constant */
|
||||
.remarkup-code .no { /* Name.Constant */
|
||||
color: #000A65;
|
||||
}
|
||||
|
||||
.remarkup-code .k, /* Keyword */
|
||||
.remarkup-code .kd, /* Keyword.Declaration */
|
||||
.remarkup-code .kn, /* Keyword.Namespace */
|
||||
.remarkup-code .kt { /* Keyword.Type */
|
||||
color: #AA4000;
|
||||
}
|
||||
|
||||
.remarkup-code .cp, /* Comment.Preproc */
|
||||
.remarkup-code .kp, /* Keyword.Pseudo */
|
||||
.remarkup-code .kr, /* Keyword.Reserved */
|
||||
.remarkup-code .nb, /* Name.Builtin */
|
||||
.remarkup-code .bp { /* Name.Builtin.Pseudo */
|
||||
color: #304A96;
|
||||
}
|
||||
|
||||
.remarkup-code .nc, /* Name.Class */
|
||||
.remarkup-code .nt, /* Name.Tag */
|
||||
.remarkup-code .vc { /* Name.Variable.Class */
|
||||
color: #00702A;
|
||||
}
|
||||
|
||||
.remarkup-code .nf, /* Name.Function */
|
||||
.remarkup-code .nx { /* Name.Other */
|
||||
color: #004012;
|
||||
}
|
||||
|
||||
.remarkup-code .o, /* Operator */
|
||||
.remarkup-code .ss { /* Literal.String.Symbol */
|
||||
color: #AA2211;
|
||||
}
|
||||
|
||||
.remarkup-code .m, /* Literal.Number */
|
||||
.remarkup-code .mf, /* Literal.Number.Float */
|
||||
.remarkup-code .mh, /* Literal.Number.Hex */
|
||||
.remarkup-code .mi, /* Literal.Number.Integer */
|
||||
.remarkup-code .mo, /* Literal.Number.Oct */
|
||||
.remarkup-code .il { /* Literal.Number.Integer.Long */
|
||||
color: #601200;
|
||||
}
|
||||
|
||||
.remarkup-code .gd { color: #A00000 } /* Generic.Deleted */
|
||||
.remarkup-code .ge { } /* Generic.Emph */
|
||||
.remarkup-code .gr { color: #FF0000 } /* Generic.Error */
|
||||
.remarkup-code .gh { color: #000080; } /* Generic.Heading */
|
||||
.remarkup-code .gi { color: #00A000 } /* Generic.Inserted */
|
||||
.remarkup-code .go { color: #808080 } /* Generic.Output */
|
||||
.remarkup-code .gp { color: #000080 } /* Generic.Prompt */
|
||||
.remarkup-code .gs { } /* Generic.Strong */
|
||||
.remarkup-code .gu { color: #800080 } /* Generic.Subheading */
|
||||
.remarkup-code .gt { color: #0040D0 } /* Generic.Traceback */
|
||||
.remarkup-code .nd { color: #AA22FF } /* Name.Decorator */
|
||||
.remarkup-code .ni { color: #999999 } /* Name.Entity */
|
||||
.remarkup-code .ne { color: #D2413A } /* Name.Exception */
|
||||
.remarkup-code .nl { color: #A0A000 } /* Name.Label */
|
||||
.remarkup-code .nn { color: #0000FF } /* Name.Namespace */
|
||||
.remarkup-code .ow { color: #AA22FF } /* Operator.Word */
|
||||
.remarkup-code .w { color: #bbbbbb } /* Text.Whitespace */
|
||||
.remarkup-code .se { color: #BB6622 } /* Literal.String.Escape */
|
||||
.remarkup-code .si { color: #BB6688 } /* Literal.String.Interpol */
|
||||
|
||||
|
Loading…
Reference in a new issue