Skip to content

Reactivate highlight.js language autodetection

What does this MR do?

This commit partly reverts commit 0d13abb1 to reactivate highlight.js language autodetection.

It does NOT revert the part that adds the nohighlight CSS-class for a predefined set of filenames (which was indeed the intended purpose of commit 0d13abb1).

Are there points in the code the reviewer needs to double check?

Not particularly, the only effect of this blob_helper is to add a CSS class to the <pre> container of the blob, to control the way highlight.js performs its syntax highlighting. (see where this helper is called at https://gitlab.com/gitlab-org/gitlab-ce/blob/master/app/views/shared/_file_hljs.html.haml#L12).

However this merge request DOES change the way the syntax highlighting is done (by bringing it back to the situation before commit 0d13abb1 where highlight.js autodetected the language itself). So we can expect some new kind of syntax highlighting problems. However in this case, the issues should be forwarded to the upstream project (https://github.com/isagalaev/highlight.js).

Why was this MR needed?

The main motivation behind this partial revert is that there is no point (IMHO) in using an "intelligent" syntax highlighter which is specifically designed to autodetect languages if it is to dictate (via the CSS class) the language to use solely based on the filename extension.

What are the relevant issue numbers / Feature requests?

Issue #665 (closed) "HLJS language autodetection / syntax highlighting fails "

Screenshots (If appropriate)

See screenshots in issue #665 (closed)

Merge request reports