Skip to content

Commit

Permalink
enhance: accept promela files
Browse files Browse the repository at this point in the history
render as plaintext until pygments v2.18 is released
  • Loading branch information
ublefo committed Apr 15, 2024
1 parent 18136c2 commit 67f9ee8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/helpers/file_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module FileHelper
extend MimeCheckHelpers

def known_extension?(extn)
allow_extensions = %w(pdf ps csv xls xlsx pas cpp c cs csv h hpp java py js html coffee scss yaml yml xml json ts r rb rmd rnw rhtml rpres tex vb sql txt md jack hack asm hdl tst out cmp vm sh bat dat ipynb css png bmp tiff tif jpeg jpg gif zip gz tar wav ogg mp3 mp4 webm aac pcm aiff flac wma alac)
allow_extensions = %w(pdf ps csv xls xlsx pas cpp c cs csv h hpp java py js html coffee scss yaml yml xml json ts r rb rmd rnw rhtml rpres tex vb sql txt md jack hack asm hdl tst out cmp vm sh bat dat ipynb css png bmp tiff tif jpeg jpg gif zip gz tar wav ogg mp3 mp4 webm aac pcm aiff flac wma alac pml)

# Allow empty or nil extensions for blobs otherwise check that it matches the allowed list
extn.nil? || extn.empty? || allow_extensions.include?(extn)
Expand Down
4 changes: 3 additions & 1 deletion app/models/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1019,10 +1019,12 @@ def self.pygments_lang(extn)
elsif ['xml'].include?(extn) then 'xml'
elsif ['sql'].include?(extn) then 'sql'
elsif ['vb'].include?(extn) then 'vbnet'
elsif ['txt', 'md', 'rmd', 'rpres', 'hdl', 'asm', 'jack', 'hack', 'tst', 'cmp', 'vm', 'sh', 'bat', 'dat', 'csv'].include?(extn) then 'text'
elsif ['txt', 'md', 'rmd', 'rpres', 'hdl', 'asm', 'jack', 'hack', 'tst', 'cmp', 'vm', 'sh', 'bat', 'dat', 'csv', 'pml'].include?(extn) then 'text'
elsif ['tex', 'rnw'].include?(extn) then 'tex'
elsif ['py'].include?(extn) then 'python'
elsif ['r'].include?(extn) then 'r'
# requres unreleased pygments v2.18 https://pygments.org/docs/lexers/#pygments.lexers.c_like.PromelaLexer
# elsif ['pml'].include?(extn) then 'promela'
else extn
end
end
Expand Down

0 comments on commit 67f9ee8

Please sign in to comment.