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
This commit is contained in:
Dmitriy Zaporozhets 2014-11-30 13:22:48 +00:00
commit f4b9a65c05

View file

@ -1,14 +1,9 @@
module BlobHelper
def highlightjs_class(blob_name)
if blob_name.include?('.')
ext = blob_name.split('.').last
return 'language-' + ext
if no_highlight_files.include?(blob_name.downcase)
'no-highlight'
else
if no_highlight_files.include?(blob_name.downcase)
'no-highlight'
else
blob_name.downcase
end
blob_name.downcase
end
end