@@ -504,26 +504,19 class RedCloth < String | |||||
504 | tatts = shelve( tatts ) if tatts |
|
504 | tatts = shelve( tatts ) if tatts | |
505 | rows = [] |
|
505 | rows = [] | |
506 |
|
506 | |||
507 | fullrow. |
|
507 | fullrow.each_line do |row| | |
508 | split( /\|$/m ). |
|
|||
509 | delete_if { |x| x.empty? }. |
|
|||
510 | each do |row| |
|
|||
511 |
|
||||
512 | ratts, row = pba( $1, 'tr' ), $2 if row =~ /^(#{A}#{C}\. )(.*)/m |
|
508 | ratts, row = pba( $1, 'tr' ), $2 if row =~ /^(#{A}#{C}\. )(.*)/m | |
513 |
|
||||
514 | cells = [] |
|
509 | cells = [] | |
515 |
|
|
510 | row.split( /(\|)(?![^\[\|]*\]\])/ )[1..-2].each do |cell| | |
516 | row.split( /\|(?![^\[\|]*\]\])/ ).each do |cell| |
|
511 | next if cell == '|' | |
517 | ctyp = 'd' |
|
512 | ctyp = 'd' | |
518 | ctyp = 'h' if cell =~ /^_/ |
|
513 | ctyp = 'h' if cell =~ /^_/ | |
519 |
|
514 | |||
520 | catts = '' |
|
515 | catts = '' | |
521 | catts, cell = pba( $1, 'td' ), $2 if cell =~ /^(_?#{S}#{A}#{C}\. ?)(.*)/ |
|
516 | catts, cell = pba( $1, 'td' ), $2 if cell =~ /^(_?#{S}#{A}#{C}\. ?)(.*)/ | |
522 |
|
517 | |||
523 | unless cell.strip.empty? |
|
518 | catts = shelve( catts ) if catts | |
524 | catts = shelve( catts ) if catts |
|
519 | cells << "\t\t\t<t#{ ctyp }#{ catts }>#{ cell }</t#{ ctyp }>" | |
525 | cells << "\t\t\t<t#{ ctyp }#{ catts }>#{ cell }</t#{ ctyp }>" |
|
|||
526 | end |
|
|||
527 | end |
|
520 | end | |
528 | ratts = shelve( ratts ) if ratts |
|
521 | ratts = shelve( ratts ) if ratts | |
529 | rows << "\t\t<tr#{ ratts }>\n#{ cells.join( "\n" ) }\n\t\t</tr>" |
|
522 | rows << "\t\t<tr#{ ratts }>\n#{ cells.join( "\n" ) }\n\t\t</tr>" |
@@ -152,12 +152,7 class ApplicationHelperTest < HelperTestCase | |||||
152 | end |
|
152 | end | |
153 |
|
153 | |||
154 | def test_wiki_links_in_tables |
|
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|" => |
|
155 | to_test = {"|[[Page|Link title]]|[[Other Page|Other title]]|\n|Cell 21|[[Last page]]|" => | |
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]]|" => |
|
|||
161 | '<tr><td><a href="/wiki/ecookbook/Page" class="wiki-page new">Link title</a></td>' + |
|
156 | '<tr><td><a href="/wiki/ecookbook/Page" class="wiki-page new">Link title</a></td>' + | |
162 | '<td><a href="/wiki/ecookbook/Other_Page" class="wiki-page new">Other title</a></td>' + |
|
157 | '<td><a href="/wiki/ecookbook/Other_Page" class="wiki-page new">Other title</a></td>' + | |
163 | '</tr><tr><td>Cell 21</td><td><a href="/wiki/ecookbook/Last_page" class="wiki-page new">Last page</a></td></tr>' |
|
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 | assert_equal expected.gsub(%r{\s+}, ''), textilizable(raw).gsub(%r{\s+}, '') |
|
213 | assert_equal expected.gsub(%r{\s+}, ''), textilizable(raw).gsub(%r{\s+}, '') | |
219 | end |
|
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 | def test_macro_hello_world |
|
238 | def test_macro_hello_world | |
222 | text = "{{hello_world}}" |
|
239 | text = "{{hello_world}}" | |
223 | assert textilizable(text).match(/Hello world!/) |
|
240 | assert textilizable(text).match(/Hello world!/) |
General Comments 0
You need to be logged in to leave comments.
Login now