Defect #25634
closedHighlight language aliases are no more supported
0%
Description
Following r16501 (released in Redmine 3.3.3), highlight language aliases (the "map" property declared in coderay-1.1.1/lib/coderay/scanners/_map.rb ) are not taken into account when checking if a language is supported.
We used to write code snippets with code class="javascript"
, but since the true JavaScript coderay scanner is called java_script.rb
, all our JS snippets aren't highlighted anymore.
Files
Related issues
Updated by Go MAEDA over 7 years ago
- File 25634-r16501.png 25634-r16501.png added
- File 25634-r16502.png 25634-r16502.png added
- Category changed from Wiki to Text formatting
- Status changed from New to Confirmed
- Priority changed from Normal to High
- Target version set to 3.2.7
- Affected version changed from 3.3.3 to 3.2.6
Updated by Go MAEDA over 7 years ago
This problem is due to Redmine::SyntaxHighlighting::CodeRay::language_supported?
.
def language_supported?(language)
::CodeRay::Scanners.list.include?(language.to_s.downcase.to_sym)
rescue
false
end
p language # => "javascript" p ::CodeRay::Scanners.list # => [:c, :clojure, ... :java_script, ... :xml, :yaml] p ::CodeRay::Scanners.list.include?(language.to_s.downcase.to_sym) # => false
Updated by Mischa The Evil over 7 years ago
Here is a quick and dirty workaround (which I haven't actually tested yet) for users who are suffering from this regression and cannot wait for a released fix:
Index: lib/redmine/syntax_highlighting.rb
===================================================================
--- lib/redmine/syntax_highlighting.rb (revision 16543)
+++ lib/redmine/syntax_highlighting.rb (working copy)
@@ -70,7 +70,8 @@
end
def language_supported?(language)
- ::CodeRay::Scanners.list.include?(language.to_s.downcase.to_sym)
+ coderay_aliases = [:'c++', :cplusplus, :ecmascript, :ecma_script, :rhtml, :eruby, :irb, :javascript, :js, :pascal, :patch, :plain, :plaintext, :xhtml, :yml]
+ ::CodeRay::Scanners.list.include?(language.to_s.downcase.to_sym) || coderay_aliases.include?(language.to_s.downcase.to_sym)
rescue
false
end
Updated by Go MAEDA over 7 years ago
- File fix-defect-25634.diff added
This is a patch to fix this issue.
Updated by Go MAEDA over 7 years ago
- File fix-defect-25634.diff fix-defect-25634.diff added
Slightly improved the patch.
Updated by Holger Just over 7 years ago
Thanks for the patch. I had indeed missed the alias names for Coderay.
Looks good to me!
Updated by Jean-Philippe Lang over 7 years ago
- Status changed from Confirmed to Resolved
- Assignee set to Jean-Philippe Lang
- Resolution set to Fixed
Patch committed, thanks.
Updated by Jean-Philippe Lang over 7 years ago
- Status changed from Resolved to Closed
Updated by Mischa The Evil over 7 years ago
- Related to Defect #26055: Three issues with Redmine::SyntaxHighlighting::CodeRay.language_supported? added
Updated by Mischa The Evil over 7 years ago
- Status changed from Closed to Reopened
Reopened in light of #26055.
Updated by Jean-Philippe Lang over 7 years ago
- Status changed from Reopened to Closed