mirror of
https://github.com/redmine/redmine.git
synced 2025-10-26 07:46:17 +01:00
Enable CommonMark alert extension (#42603).
Patch by Mizuki ISHIKAWA (user:ishikawa999). git-svn-id: https://svn.redmine.org/redmine/trunk@23724 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -34,6 +34,7 @@ module Redmine
|
||||
header_ids: nil,
|
||||
tasklist: true,
|
||||
shortcodes: false,
|
||||
alerts: true,
|
||||
}.freeze,
|
||||
|
||||
# https://github.com/gjtorikian/commonmarker#parse-options
|
||||
|
||||
@@ -68,6 +68,26 @@ module Redmine
|
||||
end
|
||||
}
|
||||
|
||||
# Allow class on div and p tags only for alert blocks
|
||||
# (must be exactly: "markdown-alert markdown-alert-*" for div, and "markdown-alert-title" for p)
|
||||
(allowlist[:attributes]["div"] ||= []) << "class"
|
||||
(allowlist[:attributes]["p"] ||= []) << "class"
|
||||
allowlist[:transformers].push lambda{|env|
|
||||
node = env[:node]
|
||||
return unless node.element?
|
||||
|
||||
case node.name
|
||||
when 'div'
|
||||
unless node['class'] =~ /\Amarkdown-alert markdown-alert-[a-z]+\z/
|
||||
node.remove_attribute('class')
|
||||
end
|
||||
when 'p'
|
||||
unless node['class'] == 'markdown-alert-title'
|
||||
node.remove_attribute('class')
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
# Allow table cell alignment by style attribute
|
||||
#
|
||||
# Only necessary if we used the TABLE_PREFER_STYLE_ATTRIBUTES
|
||||
|
||||
Reference in New Issue
Block a user