Verified Commit 0d13abb1 authored by Dmytro Zaporozhets (DZ)'s avatar Dmytro Zaporozhets (DZ) 🌴
Browse files

Specify language detection for highlight.js



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

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent ab094e67
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
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)
  end
end
+1 −1
Original line number Diff line number Diff line
@@ -8,5 +8,5 @@
        = i
  .highlight
    %pre
      %code
      %code{ class: highlightjs_class(blob.name) }
        = blob.data