From 67f9ee84630439497b651ccf932dc98a0d5dc93a Mon Sep 17 00:00:00 2001 From: ublefo <90136978+ublefo@users.noreply.github.com> Date: Thu, 11 Apr 2024 11:26:20 +1000 Subject: [PATCH] enhance: accept promela files render as plaintext until pygments v2.18 is released --- app/helpers/file_helper.rb | 2 +- app/models/task.rb | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/helpers/file_helper.rb b/app/helpers/file_helper.rb index 7523f7eb4..1cc70f557 100644 --- a/app/helpers/file_helper.rb +++ b/app/helpers/file_helper.rb @@ -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) diff --git a/app/models/task.rb b/app/models/task.rb index af7f8e398..050a379f8 100644 --- a/app/models/task.rb +++ b/app/models/task.rb @@ -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