diff options
author | Go MAEDA <maeda@farend.jp> | 2021-05-14 09:39:12 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2021-05-14 09:39:12 +0000 |
commit | 183642ba20e05e48aa0c8681f4de95457069cce4 (patch) | |
tree | d3b607c85594219478f61e328764105c7a39fcb1 /test/unit/lib | |
parent | 91379493cdde5650a6e4400cd3f55fd6b84d48e2 (diff) | |
download | redmine-183642ba20e05e48aa0c8681f4de95457069cce4.tar.gz redmine-183642ba20e05e48aa0c8681f4de95457069cce4.zip |
Markdown text sections broken by thematic breaks (horizontal rules) (#35036).
Patch by Martin Cizek.
git-svn-id: http://svn.redmine.org/redmine/trunk@20998 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/lib')
-rw-r--r-- | test/unit/lib/redmine/wiki_formatting/markdown_formatter_test.rb | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/test/unit/lib/redmine/wiki_formatting/markdown_formatter_test.rb b/test/unit/lib/redmine/wiki_formatting/markdown_formatter_test.rb index 561e7aa02..c1264f77b 100644 --- a/test/unit/lib/redmine/wiki_formatting/markdown_formatter_test.rb +++ b/test/unit/lib/redmine/wiki_formatting/markdown_formatter_test.rb @@ -180,6 +180,75 @@ class Redmine::WikiFormatting::MarkdownFormatterTest < ActionView::TestCase ) end + STR_SETEXT_LIKE = [ + # 0 + <<~STR.chomp, + # Title + STR + # 1 + <<~STR.chomp, + ## Heading 2 + + Thematic breaks - not be confused with setext headings. + + --- + + Preceding CRLF is the default for web-submitted data. + \r + ---\r + \r + + A space-only line does not mean much. + \s + --- + + End of thematic breaks. + STR + # 2 + <<~STR.chomp, + ## Heading 2 + Nulla nunc nisi, egestas in ornare vel, posuere ac libero. + STR + ] + + STR_RARE_SETEXT_LIKE = [ + # 0 + <<~STR.chomp, + # Title + STR + # 1 + <<~STR.chomp, + ## Heading 2 + + - item + one + - + not a heading + STR + # 2 + <<~STR.chomp, + ## Heading 2 + Nulla nunc nisi, egestas in ornare vel, posuere ac libero. + STR + ] + + def test_get_section_should_ignore_setext_like_text + text = STR_SETEXT_LIKE.join("\n\n") + assert_section_with_hash STR_SETEXT_LIKE[1], text, 2 + assert_section_with_hash STR_SETEXT_LIKE[2], text, 3 + end + + def test_get_section_should_ignore_rare_setext_like_text + begin + text = STR_RARE_SETEXT_LIKE.join("\n\n") + assert_section_with_hash STR_RARE_SETEXT_LIKE[1], text, 2 + assert_section_with_hash STR_RARE_SETEXT_LIKE[2], text, 3 + rescue Minitest::Assertion => e + skip "Section extraction is currently limited, see #35037. Known error: #{e.message}" + end + assert_not "This test should be adjusted when fixing the known error." + end + def test_should_support_underlined_text text = 'This _text_ should be underlined' assert_equal '<p>This <u>text</u> should be underlined</p>', @formatter.new(text).to_html.strip |