Fix reference to the deleted Redcarpet-based Redmine::WikiFormatting::Markdown::HtmlParser class by porting the HtmlParser class for the CommonMark formatter (#40149, #41513).

git-svn-id: https://svn.redmine.org/redmine/trunk@23154 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA
2024-10-21 05:45:37 +00:00
parent 5407fea873
commit 90f34d9d47

View File

@@ -20,7 +20,33 @@
module Redmine
module WikiFormatting
module CommonMark
HtmlParser = Redmine::WikiFormatting::Markdown::HtmlParser
class HtmlParser < Redmine::WikiFormatting::HtmlParser
self.tags = tags.merge(
'b' => {:pre => '**', :post => '**'},
'strong' => {:pre => '**', :post => '**'},
'i' => {:pre => '*', :post => '*'},
'em' => {:pre => '*', :post => '*'},
'u' => {:pre => '_', :post => '_'},
'strike' => {:pre => '~~', :post => '~~'},
'h1' => {:pre => "\n\n# ", :post => "\n\n"},
'h2' => {:pre => "\n\n## ", :post => "\n\n"},
'h3' => {:pre => "\n\n### ", :post => "\n\n"},
'h4' => {:pre => "\n\n#### ", :post => "\n\n"},
'h5' => {:pre => "\n\n##### ", :post => "\n\n"},
'h6' => {:pre => "\n\n###### ", :post => "\n\n"},
'th' => {:pre => '*', :post => "*\n"},
'td' => {:pre => '', :post => "\n"},
'a' => lambda do |node|
if node.content.present? && node.attributes.key?('href')
%| [#{node.content}](#{node.attributes['href'].value}) |
elsif node.attributes.key?('href')
%| #{node.attributes['href'].value} |
else
node.content
end
end
)
end
end
end
end