Skip to content

Commit

Permalink
Fixed exception when converting an HTML table to native kramdown elem…
Browse files Browse the repository at this point in the history
…ents

This fixes #101 which didn't provide a general solution.
  • Loading branch information
gettalong committed Jun 4, 2014
1 parent bb26b60 commit 4705ca7
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/kramdown/parser/html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ def convert_table(el)
if td.attr['style']
td.attr['style'].slice!(/(?:;\s*)?text-align:\s+(center|left|right)/)
td.attr.delete('style') if td.attr['style'].strip.empty?
$1.to_sym
$1 ? $1.to_sym : :default
else
:default
end
Expand Down
1 change: 1 addition & 0 deletions test/test_files.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def tidy_output(out)
'test/testcases/block/12_extension/options3.text', # bc of options option
'test/testcases/block/09_html/content_model/tables.text', # bc of parse_block_html option
'test/testcases/block/09_html/html_to_native/header.text', # bc of auto_ids option that interferes
'test/testcases/block/09_html/html_to_native/table_simple.text', # bc of tr style attr getting removed
'test/testcases/block/09_html/simple.text', # bc of webgen:block elements
'test/testcases/block/11_ial/simple.text', # bc of change of ordering of attributes in header
'test/testcases/span/extension/comment.text', # bc of comment text modifications (can this be avoided?)
Expand Down
13 changes: 13 additions & 0 deletions test/testcases/block/09_html/html_to_native/table_simple.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@
</tfoot>
</table>

<table class="examples">
<tbody>
<tr>
<td style="text-align: left">Usage</td>
<td style="width: 10em">Output</td>
</tr>
<tr>
<td style="text-align: left">Some *data*</td>
<td>Some more</td>
</tr>
</tbody>
</table>

<table class="examples">
<tr>
<th>Usage</th>
Expand Down
15 changes: 15 additions & 0 deletions test/testcases/block/09_html/html_to_native/table_simple.text
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,21 @@ locker
</tfoot>
</table>

<table class="examples">
<tr>
<td style="text-align: left">Usage</td>
<td style="width: 10em">
Output
</td>
</tr>
<tr>
<td style="text-align: left">Some *data*</td>
<td>
Some more
</td>
</tr>
</table>

<table class="examples">
<tr>
<th>Usage</th>
Expand Down

0 comments on commit 4705ca7

Please sign in to comment.