Skip to content

Commit

Permalink
feat: support for line breaks and paragraphs in html tables (#13)
Browse files Browse the repository at this point in the history
* feat: support for line breaks and paragraphs in html tables

* obey rubocop
  • Loading branch information
as-op authored Sep 17, 2024
1 parent 83c3541 commit d9f95d2
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 111 deletions.
4 changes: 3 additions & 1 deletion lib/md_to_pdf/elements/html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,10 @@ def data_inlinehtml_tag(tag, node, opts)
result.push(data_inline_image_tag(sub, node, opts))
when 'ul', 'ol'
result.concat(data_inlinehtml_list_tag(sub, node, opts))
when 'label', 'p', 'li'
when 'label', 'li'
result.concat(data_inlinehtml_tag(sub, node, opts))
when 'p'
result.concat(data_inlinehtml_tag(sub, node, opts)).push(text_hash_raw("\n", current_opts))
when 'br'
result.push(text_hash_raw("\n", current_opts))
when 'input'
Expand Down
7 changes: 7 additions & 0 deletions spec/fixtures/table/linebreaks_in_cell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
With paragraphs:
<table><tbody><tr><td><p>First</p><p><br></p><p><br></p><p>Fourth</p></td><td><p>First</p><p>Second</p></td></tr></tbody></table>

<br>

With breaks:
<table><tbody><tr><td>First<br><br><br>Fourth</td><td>First<br>Second</td></tr></tbody></table>
2 changes: 2 additions & 0 deletions spec/fixtures/table/paragraphs_in_cell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

<table><tr><td><p>1</p><p>2</p><p>3</p></td></tr></table>
Loading

0 comments on commit d9f95d2

Please sign in to comment.