summaryrefslogtreecommitdiffstats
path: root/lib/redmine/wiki_formatting/markdown/formatter.rb
diff options
context:
space:
mode:
authorMarius Balteanu <marius.balteanu@zitec.com>2021-08-15 21:00:16 +0000
committerMarius Balteanu <marius.balteanu@zitec.com>2021-08-15 21:00:16 +0000
commitb7798e6e1c0c5db75b20a83a6ba4a96f83052392 (patch)
tree10c2d0bc89a404d43f38a41080ab9475241a2df1 /lib/redmine/wiki_formatting/markdown/formatter.rb
parent5699253da6330447f7a7d3b4cf8a238f9d4608cf (diff)
downloadredmine-b7798e6e1c0c5db75b20a83a6ba4a96f83052392.tar.gz
redmine-b7798e6e1c0c5db75b20a83a6ba4a96f83052392.zip
Unify code block and add "data-language" attribute with the user-supplied language for Textile and Markdown formaters (#35104).
Patch by Martin Cizek. git-svn-id: http://svn.redmine.org/redmine/trunk@21183 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/redmine/wiki_formatting/markdown/formatter.rb')
-rw-r--r--lib/redmine/wiki_formatting/markdown/formatter.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/redmine/wiki_formatting/markdown/formatter.rb b/lib/redmine/wiki_formatting/markdown/formatter.rb
index 418ab8b14..44d65248f 100644
--- a/lib/redmine/wiki_formatting/markdown/formatter.rb
+++ b/lib/redmine/wiki_formatting/markdown/formatter.rb
@@ -38,12 +38,14 @@ module Redmine
def block_code(code, language)
if language.present? && Redmine::SyntaxHighlighting.language_supported?(language)
- "<pre><code class=\"#{CGI.escapeHTML language} syntaxhl\">" +
- Redmine::SyntaxHighlighting.highlight_by_language(code, language) +
- "</code></pre>"
+ html = Redmine::SyntaxHighlighting.highlight_by_language(code, language)
+ classattr = " class=\"#{CGI.escapeHTML language} syntaxhl\""
else
- "<pre>" + CGI.escapeHTML(code) + "</pre>"
+ html = CGI.escapeHTML(code)
end
+ # original language for extension development
+ langattr = " data-language=\"#{CGI.escapeHTML language}\"" if language.present?
+ "<pre><code#{classattr}#{langattr}>#{html}</code></pre>"
end
def image(link, title, alt_text)