Commit f4b9a65c authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'reactivate-hljs-autodetection' into 'master'

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 "HLJS language autodetection / syntax highlighting fails "

### Screenshots (If appropriate)

See screenshots in issue #665

See merge request !232
parents c8a2d041 b8fcaa7f
module BlobHelper
def highlightjs_class(blob_name)
if blob_name.include?('.')
ext = blob_name.split('.').last
return 'language-' + ext
else
if no_highlight_files.include?(blob_name.downcase)
'no-highlight'
else
blob_name.downcase
end
end
end
def no_highlight_files
%w(credits changelog copying copyright license authors)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment