From 24b4c5f48dc0a8cf7896efe8cd205b1f506d8c19 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Fri, 12 Mar 2010 13:43:11 +0000 Subject: [PATCH] Fixed: text formatting breaks when using parenthesis inside bold tags (#1334). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3563 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/redcloth3.rb | 19 ++++++++++--------- .../wiki_formatting/textile_formatter_test.rb | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/lib/redcloth3.rb b/lib/redcloth3.rb index 37816a06a..1e3d31ab1 100644 --- a/lib/redcloth3.rb +++ b/lib/redcloth3.rb @@ -380,14 +380,12 @@ class RedCloth3 < String re = case rtype when :limit - /(^|[>\s\(]) - (#{QTAGS_JOIN}|) - (#{rcq}) - (#{C}) - (?::(\S+?))? - (\w|[^\s].*?[^\s]) + /(^|[>\s\(]) # sta + (#{QTAGS_JOIN}|) # oqs + (#{rcq}) # qtag + (\w|[^\s].*?[^\s]) # content #{rcq} - (#{QTAGS_JOIN}|) + (#{QTAGS_JOIN}|) # oqa (?=[[:punct:]]|\s|\)|$)/x else /(#{rcq}) @@ -772,13 +770,16 @@ class RedCloth3 < String case rtype when :limit - sta,oqs,qtag,atts,cite,content,oqa = $~[1..7] + sta,oqs,qtag,content,oqa = $~[1..6] + atts = nil + if content =~ /^(#{C})(.+)$/ + atts, content = $~[1..2] + end else qtag,atts,cite,content = $~[1..4] sta = '' end atts = pba( atts ) - atts << " cite=\"#{ cite }\"" if cite atts = shelve( atts ) if atts "#{ sta }#{ oqs }<#{ ht }#{ atts }>#{ content }#{ oqa }" diff --git a/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb b/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb index 49a75cd0f..8cb98ba51 100644 --- a/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb +++ b/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb @@ -32,6 +32,24 @@ class Redmine::WikiFormatting::TextileFormatterTest < HelperTestCase "~" => 'sub' # subscript } + def test_modifiers + to_test = { + '*bold*' => 'bold', + 'before *bold*' => 'before bold', + '*bold* after' => 'bold after', + '*two words*' => 'two words', + '*two*words*' => 'two*words', + '*two * words*' => 'two * words', + '*two* *words*' => 'two words', + '*(two)* *(words)*' => '(two) (words)', + # with class + '*(foo)two words*' => 'two words', + } + to_test.each do |text, expected| + assert_equal "

#{expected}

", @formatter.new(text).to_html + end + end + def test_modifiers_combination MODIFIERS.each do |m1, tag1| MODIFIERS.each do |m2, tag2| -- 2.39.5