プロジェクト

全般

プロフィール

Vote #78406

完了

Highlight language aliases are no more supported

Admin Redmine さんが約2年前に追加. 約2年前に更新.

ステータス:
Closed
優先度:
高め
担当者:
-
カテゴリ:
Text formatting_26
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
26
version_id:
128
issue_org_id:
25634
author_id:
247366
assigned_to_id:
1
comments:
12
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
126
ステータス-->[Closed]

説明

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.


journals

Confirmed in trunk. r16502 have broken syntax highlighting.

*r16501 (good):*
!{border: 1px solid #ddd}.25634-r16501.png!

*r16502 (bad):*
!{border: 1px solid #ddd}.25634-r16502.png!
--------------------------------------------------------------------------------
This problem is due to @Redmine::SyntaxHighlighting::CodeRay::language_supported?@.

<pre><code class="ruby">
def language_supported?(language)
::CodeRay::Scanners.list.include?(language.to_s.downcase.to_sym)
rescue
false
end
</code></pre>

<pre>
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
</pre>
--------------------------------------------------------------------------------
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:
<pre><code class="patch">
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
</code></pre>
--------------------------------------------------------------------------------
This is a patch to fix this issue.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Slightly improved the patch.
--------------------------------------------------------------------------------
Thanks for the patch. I had indeed missed the alias names for Coderay.

Looks good to me!
--------------------------------------------------------------------------------
Patch committed, thanks.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Reopened in light of #26055.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------


related_issues

relates,Closed,26055,Three issues with Redmine::SyntaxHighlighting::CodeRay.language_supported?

Admin Redmine さんが約2年前に更新

  • カテゴリText formatting_26 にセット
  • 対象バージョン3.2.7_128 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0