diff options
author | Go MAEDA <maeda@farend.jp> | 2019-08-11 05:01:37 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2019-08-11 05:01:37 +0000 |
commit | f5c7a4a4208c9c146544b4498de3a08761cbc55a (patch) | |
tree | 8612620b530885d8e69b3c122281312b35255e31 /lib/redmine/wiki_formatting | |
parent | 3c91a3d5b2f9a2ce55b941ee68fbaa596b5b3052 (diff) | |
download | redmine-f5c7a4a4208c9c146544b4498de3a08761cbc55a.tar.gz redmine-f5c7a4a4208c9c146544b4498de3a08761cbc55a.zip |
Convert HTML links to Textile/Markdown links when creating an issue from an email (#31695).
Patch by Yuichi HARADA.
git-svn-id: http://svn.redmine.org/redmine/trunk@18361 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/redmine/wiki_formatting')
-rw-r--r-- | lib/redmine/wiki_formatting/html_parser.rb | 5 | ||||
-rw-r--r-- | lib/redmine/wiki_formatting/markdown/html_parser.rb | 3 | ||||
-rw-r--r-- | lib/redmine/wiki_formatting/textile/html_parser.rb | 3 |
3 files changed, 8 insertions, 3 deletions
diff --git a/lib/redmine/wiki_formatting/html_parser.rb b/lib/redmine/wiki_formatting/html_parser.rb index 80f15b72c..f6f9639e0 100644 --- a/lib/redmine/wiki_formatting/html_parser.rb +++ b/lib/redmine/wiki_formatting/html_parser.rb @@ -36,7 +36,7 @@ module Redmine doc.scrub!(WikiTags.new(tags)) doc.scrub!(:newline_block_elements) - Loofah.remove_extraneous_whitespace(doc.text).strip.squeeze(' ').gsub(/^ +/, '') + Loofah.remove_extraneous_whitespace(doc.text(:encode_special_chars => false)).strip.squeeze(' ').gsub(/^ +/, '') end class WikiTags < ::Loofah::Scrubber @@ -54,6 +54,9 @@ module Redmine when String node.add_next_sibling Nokogiri::XML::Text.new(formatting, node.document) node.remove + when Proc + node.add_next_sibling formatting.call(node) + node.remove else CONTINUE end diff --git a/lib/redmine/wiki_formatting/markdown/html_parser.rb b/lib/redmine/wiki_formatting/markdown/html_parser.rb index 8cc0eaccd..c9f83ffe6 100644 --- a/lib/redmine/wiki_formatting/markdown/html_parser.rb +++ b/lib/redmine/wiki_formatting/markdown/html_parser.rb @@ -34,7 +34,8 @@ module Redmine '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"} + 'h6' => {:pre => "\n\n###### ", :post => "\n\n"}, + 'a' => lambda {|node| node.content.present? ? %| [#{node.content}](#{node.attributes['href'].value}) | : %| #{node.attributes['href'].value} |} ) end end diff --git a/lib/redmine/wiki_formatting/textile/html_parser.rb b/lib/redmine/wiki_formatting/textile/html_parser.rb index 72890871e..7d9173478 100644 --- a/lib/redmine/wiki_formatting/textile/html_parser.rb +++ b/lib/redmine/wiki_formatting/textile/html_parser.rb @@ -34,7 +34,8 @@ module Redmine 'h3' => {:pre => "\n\nh3. ", :post => "\n\n"}, 'h4' => {:pre => "\n\nh4. ", :post => "\n\n"}, 'h5' => {:pre => "\n\nh5. ", :post => "\n\n"}, - 'h6' => {:pre => "\n\nh6. ", :post => "\n\n"} + 'h6' => {:pre => "\n\nh6. ", :post => "\n\n"}, + 'a' => lambda {|node| node.content.present? ? %| "#{node.content}":#{node.attributes['href'].value} | : %| #{node.attributes['href'].value} |} ) end end |