New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 9389 link

Starred by 4 users

Issue metadata

Status: Released
Owner: ----
Closed: Jul 10
ReleasedIn: 526.0

Sign in to add a comment

Enable HighlightJS Clojure support for PolyGerrit

Reported by, Jul 4

Issue description

Affected Version:

What steps will reproduce the problem?
1. Switch to the PolyGerrit GUI
2. Look at a .clj, .cljs, or .edn file in a Gerrit review

* What is the expected output?

I'd expect to see clojure syntax highlighting as shown on the HightlightJS website, with symbols, labels, parens, function calls etc. highlighted.

* What do you see instead?

The code isn't highlighted in any specific Clojure manner, only quoted strings

This is against 2.15.2, would be nice to see this included in 2.15.3 if possible.

Project Member

Comment 2 by, Jul 8

I can confirm the problem.

I tried to debug it, and to simplify the debug session,
I've built highlight.js without minification (just copied
non-minified version over lib/highlightjs/highlight.min.js

While debugging, I can see, that the language was correctly
discovered as clojure (extension was .clj) and that the
process method correctly processing the test Clojure code,
line by line. At the end the annotated code is shown, but
nothing happened.

For example the first line:

"(def ^:dynamic chunk-size 17)"

is converted to:

<div class="style-scope gr-diff contentText" data-side="right">(<hl class="gr-diff gr-syntax gr-syntax-name">def</hl> ^:dynamic chunk-size <hl class="gr-diff gr-syntax gr-syntax-number">17</hl>)

Here is the screenshot: [1].

* [1]
Project Member

Comment 3 by, Jul 8

Project Member

Comment 4 by, Jul 8

Status: Accepted (was: New)
OK, comparing this to working Java source highlighting, I see in fact this difference,
on this line:

"class Demo extends Sum {"

hljs producing:

<div class="style-scope gr-diff contentText" data-side="right">
<hl class="gr-diff gr-syntax gr-syntax-keyword">class</hl> <hl class="gr-diff gr-syntax gr-syntax-title">Demo</hl>
<hl class="gr-diff gr-syntax gr-syntax-keyword">extends</hl> <hl class="gr-diff gr-syntax gr-syntax-title">Sum</hl>{</div>

So clearly, highlight.js doing something different on Clojure code.

I thing the reason is how the language defined in HL.js. While
in Java mode the keywords are defined as keywords [1], in Clojure
mode they are defined as builtin-name: [2].

The styling difference is: gr-syntax-name vs. gr-syntax-keyword.

It appears that there is no style definition for gr-syntax-name,
even though this is accepted in whitelist: [3].

Not sure, if it the correct way to fix it: style gr-syntax-name exactly
the same way as gr-syntax-keyword fixed syntax highlighting for Clojure.

Here the screenshot in dark theme: [4].

Hint: to activate dark theme, just open the JS console in your browser
and run: localStorage.setItem("dark-theme", "1");


Project Member

Comment 5 by, Jul 8

It may be whitelisted but did we add it to the styles with a colour?
Project Member

Comment 7 by, Jul 8

Status: ChangeUnderReview (was: Accepted)
Project Member

Comment 9 by, Jul 10

Status: Submitted (was: ChangeUnderReview)
Labels: FixedIn-2.15.3
Status: Released (was: Submitted)
Project Member

Comment 12 by, Jul 24

ReleasedIn: 526.0

Sign in to add a comment