@@ -504,27 +504,20 class RedCloth < String | |||
|
504 | 504 | tatts = shelve( tatts ) if tatts |
|
505 | 505 | rows = [] |
|
506 | 506 | |
|
507 | fullrow. | |
|
508 | split( /\|$/m ). | |
|
509 | delete_if { |x| x.empty? }. | |
|
510 | each do |row| | |
|
511 | ||
|
507 | fullrow.each_line do |row| | |
|
512 | 508 | ratts, row = pba( $1, 'tr' ), $2 if row =~ /^(#{A}#{C}\. )(.*)/m |
|
513 | ||
|
514 | 509 | cells = [] |
|
515 |
|
|
|
516 | row.split( /\|(?![^\[\|]*\]\])/ ).each do |cell| | |
|
510 | row.split( /(\|)(?![^\[\|]*\]\])/ )[1..-2].each do |cell| | |
|
511 | next if cell == '|' | |
|
517 | 512 | ctyp = 'd' |
|
518 | 513 | ctyp = 'h' if cell =~ /^_/ |
|
519 | 514 | |
|
520 | 515 | catts = '' |
|
521 | 516 | catts, cell = pba( $1, 'td' ), $2 if cell =~ /^(_?#{S}#{A}#{C}\. ?)(.*)/ |
|
522 | 517 | |
|
523 | unless cell.strip.empty? | |
|
524 | 518 |
|
|
525 | 519 |
|
|
526 | 520 |
|
|
527 | end | |
|
528 | 521 | ratts = shelve( ratts ) if ratts |
|
529 | 522 | rows << "\t\t<tr#{ ratts }>\n#{ cells.join( "\n" ) }\n\t\t</tr>" |
|
530 | 523 | end |
@@ -152,12 +152,7 class ApplicationHelperTest < HelperTestCase | |||
|
152 | 152 | end |
|
153 | 153 | |
|
154 | 154 | def test_wiki_links_in_tables |
|
155 | to_test = {"|Cell 11|Cell 12|Cell 13|\n|Cell 21|Cell 22||\n|Cell 31||Cell 33|" => | |
|
156 | '<tr><td>Cell 11</td><td>Cell 12</td><td>Cell 13</td></tr>' + | |
|
157 | '<tr><td>Cell 21</td><td>Cell 22</td></tr>' + | |
|
158 | '<tr><td>Cell 31</td><td>Cell 33</td></tr>', | |
|
159 | ||
|
160 | "|[[Page|Link title]]|[[Other Page|Other title]]|\n|Cell 21|[[Last page]]|" => | |
|
155 | to_test = {"|[[Page|Link title]]|[[Other Page|Other title]]|\n|Cell 21|[[Last page]]|" => | |
|
161 | 156 | '<tr><td><a href="/wiki/ecookbook/Page" class="wiki-page new">Link title</a></td>' + |
|
162 | 157 | '<td><a href="/wiki/ecookbook/Other_Page" class="wiki-page new">Other title</a></td>' + |
|
163 | 158 | '</tr><tr><td>Cell 21</td><td><a href="/wiki/ecookbook/Last_page" class="wiki-page new">Last page</a></td></tr>' |
@@ -218,6 +213,28 EXPECTED | |||
|
218 | 213 | assert_equal expected.gsub(%r{\s+}, ''), textilizable(raw).gsub(%r{\s+}, '') |
|
219 | 214 | end |
|
220 | 215 | |
|
216 | def test_table | |
|
217 | raw = <<-RAW | |
|
218 | This is a table with empty cells: | |
|
219 | ||
|
220 | |cell11|cell12|| | |
|
221 | |cell21||cell23| | |
|
222 | |cell31|cell32|cell33| | |
|
223 | RAW | |
|
224 | ||
|
225 | expected = <<-EXPECTED | |
|
226 | <p>This is a table with empty cells:</p> | |
|
227 | ||
|
228 | <table> | |
|
229 | <tr><td>cell11</td><td>cell12</td><td></td></tr> | |
|
230 | <tr><td>cell21</td><td></td><td>cell23</td></tr> | |
|
231 | <tr><td>cell31</td><td>cell32</td><td>cell33</td></tr> | |
|
232 | </table> | |
|
233 | EXPECTED | |
|
234 | ||
|
235 | assert_equal expected.gsub(%r{\s+}, ''), textilizable(raw).gsub(%r{\s+}, '') | |
|
236 | end | |
|
237 | ||
|
221 | 238 | def test_macro_hello_world |
|
222 | 239 | text = "{{hello_world}}" |
|
223 | 240 | assert textilizable(text).match(/Hello world!/) |
General Comments 0
You need to be logged in to leave comments.
Login now