summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/redmine/wiki_formatting/common_mark/html_parser.rb28
1 files changed, 27 insertions, 1 deletions
diff --git a/lib/redmine/wiki_formatting/common_mark/html_parser.rb b/lib/redmine/wiki_formatting/common_mark/html_parser.rb
index ba79dfc14..3e8cf6671 100644
--- a/lib/redmine/wiki_formatting/common_mark/html_parser.rb
+++ b/lib/redmine/wiki_formatting/common_mark/html_parser.rb
@@ -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