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