Defect #31695 » fixed-31695.patch
lib/redmine/wiki_formatting/html_parser.rb | ||
---|---|---|
36 | 36 |
doc.scrub!(WikiTags.new(tags)) |
37 | 37 |
doc.scrub!(:newline_block_elements) |
38 | 38 | |
39 |
Loofah.remove_extraneous_whitespace(doc.text).strip.squeeze(' ').gsub(/^ +/, '') |
|
39 |
Loofah.remove_extraneous_whitespace(doc.text(:encode_special_chars => false)).strip.squeeze(' ').gsub(/^ +/, '')
|
|
40 | 40 |
end |
41 | 41 | |
42 | 42 |
class WikiTags < ::Loofah::Scrubber |
... | ... | |
54 | 54 |
when String |
55 | 55 |
node.add_next_sibling Nokogiri::XML::Text.new(formatting, node.document) |
56 | 56 |
node.remove |
57 |
when Proc |
|
58 |
node.add_next_sibling formatting.call(node) |
|
59 |
node.remove |
|
57 | 60 |
else |
58 | 61 |
CONTINUE |
59 | 62 |
end |
lib/redmine/wiki_formatting/markdown/html_parser.rb | ||
---|---|---|
34 | 34 |
'h3' => {:pre => "\n\n### ", :post => "\n\n"}, |
35 | 35 |
'h4' => {:pre => "\n\n#### ", :post => "\n\n"}, |
36 | 36 |
'h5' => {:pre => "\n\n##### ", :post => "\n\n"}, |
37 |
'h6' => {:pre => "\n\n###### ", :post => "\n\n"} |
|
37 |
'h6' => {:pre => "\n\n###### ", :post => "\n\n"}, |
|
38 |
'a' => lambda {|node| node.content.present? ? %Q| [#{node.content}](#{node.attributes['href'].value}) | : %Q| #{node.attributes['href'].value} |} |
|
38 | 39 |
) |
39 | 40 |
end |
40 | 41 |
end |
lib/redmine/wiki_formatting/textile/html_parser.rb | ||
---|---|---|
34 | 34 |
'h3' => {:pre => "\n\nh3. ", :post => "\n\n"}, |
35 | 35 |
'h4' => {:pre => "\n\nh4. ", :post => "\n\n"}, |
36 | 36 |
'h5' => {:pre => "\n\nh5. ", :post => "\n\n"}, |
37 |
'h6' => {:pre => "\n\nh6. ", :post => "\n\n"} |
|
37 |
'h6' => {:pre => "\n\nh6. ", :post => "\n\n"}, |
|
38 |
'a' => lambda {|node| node.content.present? ? %Q| "#{node.content}":#{node.attributes['href'].value} | : %Q| #{node.attributes['href'].value} |} |
|
38 | 39 |
) |
39 | 40 |
end |
40 | 41 |
end |
test/unit/lib/redmine/wiki_formatting/markdown_html_parser_test.rb | ||
---|---|---|
28 | 28 |
def test_should_convert_tags |
29 | 29 |
assert_equal 'A **simple** html snippet.', |
30 | 30 |
@parser.to_text('<p>A <b>simple</b> html snippet.</p>') |
31 | ||
32 |
assert_equal 'foo [bar](http://example.com/) baz', |
|
33 |
@parser.to_text('foo<a href="http://example.com/">bar</a>baz') |
|
34 |
assert_equal 'foo http://example.com/ baz', |
|
35 |
@parser.to_text('foo<a href="http://example.com/"></a>baz') |
|
31 | 36 |
end |
32 | 37 |
end |
test/unit/lib/redmine/wiki_formatting/textile_html_parser_test.rb | ||
---|---|---|
28 | 28 |
def test_should_convert_tags |
29 | 29 |
assert_equal 'A *simple* html snippet.', |
30 | 30 |
@parser.to_text('<p>A <b>simple</b> html snippet.</p>') |
31 | ||
32 |
assert_equal 'foo "bar":http://example.com/ baz', |
|
33 |
@parser.to_text('foo<a href="http://example.com/">bar</a>baz') |
|
34 |
assert_equal 'foo http://example.com/ baz', |
|
35 |
@parser.to_text('foo<a href="http://example.com/"></a>baz') |
|
31 | 36 |
end |
32 | 37 |
end |