Syntax highlighting for JavaScript seems to be broken
Added by Pablo Yanez Trujillo about 7 years ago
Hi
I have an installation for redmine-3.3.3. I configured it to use Markdown.
Syntax highlighting works, the HTML output for
```c int main(void) { return 0; }; ```
contains lines like this:
<ppre><ccode class="c syntaxhl"> <span class="CodeRay"><span class="predefined-type">int</span> main(<span class="directive">void</span>) ... </ccode><ppre>
Note: I changed the tags from pre and code to ppre and ccode in order to avaoid parse errors here. A pre in a pre leads to an parsing error.
The following code
```javascript console.log("hi"); ```
yields
<ppre>
console.log("hi");
</ppre>
For some reason redmine thinks that coderay is not able to parse that. I've tried different names, javascript, JavaScript, js, the result is always the same.
If I log in per SSH into my server and create a js file and run coderay dummy.js, it displays a highlighted version on the terminal. So it seems that coderay is working correctly. I'm using CodeRay 1.1.2.
Does anybody know why javascript is not highlighted properly?
Replies (3)
RE: Syntax highlighting for JavaScript seems to be broken - Added by Pablo Yanez Trujillo about 7 years ago
I know where the problem is:
require 'coderay' CodeRay::Scanners.list => [:go, :text, :python, :scanner, :yaml, :debug, :groovy, :c, :java, :cpp, :sass, :ruby, :diff, :php, :haml, :html, :delphi, :xml, :erb, :css, :taskpaper, :lua, :raydebug, :sql, :json, :clojure, :java_script]
Using
```java_script console.log("hi"); ```
does the trick. It would be nice if you could put that in the documentation.
RE: Syntax highlighting for JavaScript seems to be broken - Added by Mischa The Evil about 7 years ago
RE: Syntax highlighting for JavaScript seems to be broken - Added by Pablo Yanez Trujillo about 7 years ago
Mischa The Evil wrote:
This was a known defect introduced in r16501 (which is in 3.2.6 and 3.3.3 releases) and fixed in r16568 (which is in 3.2.7 and 3.3.4 releases). See #25634.
I'd suggest you update your Redmine instance to a current release (either 3.4.3 or 3.3.5, which btw fixes some XSS vulnerabilities too).
Thanks for your reply. I'll update my version in the next couple of days.