diff --git a/lib/redcloth3.rb b/lib/redcloth3.rb index 6c1d9fd..0e3258c 100644 --- a/lib/redcloth3.rb +++ b/lib/redcloth3.rb @@ -1011,7 +1011,7 @@ class RedCloth3 < String end OFFTAGS = /(code|pre|kbd|notextile)/ - OFFTAG_MATCH = /(?:(<\/#{ OFFTAGS }>)|(<#{ OFFTAGS }[^>]*>))(.*?)(?=<\/?#{ OFFTAGS }|\Z)/mi + OFFTAG_MATCH = /(?:(<\/#{ OFFTAGS }>)|(<#{ OFFTAGS }[^>]*>))(.*?)(?=<\/?#{ OFFTAGS }\W|\Z)/mi OFFTAG_OPEN = /<#{ OFFTAGS }/ OFFTAG_CLOSE = /<\/?#{ OFFTAGS }/ HASTAG_MATCH = /(<\/?\w[^\n]*?>)/m diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb index 09982e3..62895e6 100644 --- a/test/unit/helpers/application_helper_test.rb +++ b/test/unit/helpers/application_helper_test.rb @@ -251,7 +251,29 @@ RAW to_test.each { |text, result| assert_equal result, textilizable(text) } end - def syntax_highlight + def test_pre_tags + raw = <<-RAW +Before + +
++ +After +RAW + + expected = <<-EXPECTED +32 +
Before
++<prepared-statement-cache-size>32</prepared-statement-cache-size> ++
After
+EXPECTED + + assert_equal expected.gsub(%r{[\r\n\t]}, ''), textilizable(raw).gsub(%r{[\r\n\t]}, '') + end + + def test_syntax_highlight raw = <<-RAW
# Some ruby code here