Commit 0d13abb1c8d527f2a6e6b97e34899e9b35f264bc

Authored by Dmitriy Zaporozhets
1 parent ab094e67

Specify language detection for highlight.js

Because I am tired of CHANGELOG highlighted as sql file :)

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
app/helpers/blob_helper.rb 0 → 100644
... ... @@ -0,0 +1,18 @@
  1 +module BlobHelper
  2 + def highlightjs_class(blob_name)
  3 + if blob_name.include?('.')
  4 + ext = blob_name.split('.').last
  5 + return 'language-' + ext
  6 + else
  7 + if no_highlight_files.include?(blob_name.downcase)
  8 + 'no-highlight'
  9 + else
  10 + blob_name.downcase
  11 + end
  12 + end
  13 + end
  14 +
  15 + def no_highlight_files
  16 + %w(credits changelog copying copyright license authors)
  17 + end
  18 +end
... ...
app/views/shared/_file_hljs.html.haml
... ... @@ -8,5 +8,5 @@
8 8 = i
9 9 .highlight
10 10 %pre
11   - %code
  11 + %code{ class: highlightjs_class(blob.name) }
12 12 = blob.data
... ...