diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-01-19 20:38:48 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-01-19 20:38:48 +0000 |
commit | b7b1f640798a295a4d86f020a6888181cd9ad915 (patch) | |
tree | d308fa36640386e997f3a080d4c71581333a3cc5 | |
parent | 0bc87002d297c37019a25de1ae02a63f182b108b (diff) | |
download | redmine-b7b1f640798a295a4d86f020a6888181cd9ad915.tar.gz redmine-b7b1f640798a295a4d86f020a6888181cd9ad915.zip |
Faster textile table parsing by using a single scan instead of a regexp matching for each cell (#18883).
git-svn-id: http://svn.redmine.org/redmine/trunk@13918 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | lib/redcloth3.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/redcloth3.rb b/lib/redcloth3.rb index 0386589f6..eacd6d920 100644 --- a/lib/redcloth3.rb +++ b/lib/redcloth3.rb @@ -529,13 +529,13 @@ class RedCloth3 < String fullrow.each_line do |row| ratts, row = pba( $1, 'tr' ), $2 if row =~ /^(#{A}#{C}\. )(.*)/m cells = [] - row.split( /(\|)(?![^\[\|]*\]\])/ )[1..-2].each do |cell| - next if cell == '|' + # the regexp prevents wiki links with a | from being cut as cells + row.scan(/\|(_?#{S}#{A}#{C}\. ?)?((\[\[[^|\]]*\|[^|\]]*\]\]|[^|])*?)(?=\|)/) do |modifiers, cell| ctyp = 'd' - ctyp = 'h' if cell =~ /^_/ + ctyp = 'h' if modifiers && modifiers =~ /^_/ catts = nil - catts, cell = pba( $1, 'td' ), $2 if cell =~ /^(_?#{S}#{A}#{C}\. ?)(.*)/ + catts = pba( modifiers, 'td' ) if modifiers catts = shelve( catts ) if catts cells << "\t\t\t<t#{ ctyp }#{ catts }>#{ cell }</t#{ ctyp }>" |