Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add newlines around tables #80

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Html2Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ static function iterateOverNode($node, $prevName = null, $in_pre = false, $is_of
case "ol":
case "ul":
case "pre":
case "table":
// add two newlines
$output = "\n\n";
break;
Expand Down Expand Up @@ -396,6 +397,7 @@ static function iterateOverNode($node, $prevName = null, $in_pre = false, $is_of
case "h5":
case "h6":
case "pre":
case "table":
case "p":
// add two lines
$output .= "\n\n";
Expand Down
1 change: 1 addition & 0 deletions tests/full_email.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ You're currently finding about
per day

[Number of cats found]

---------------------------------------------------------------

Your last cat was found two days ago.
Expand Down
2 changes: 1 addition & 1 deletion tests/table.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ <h1>Hello, World!</h1>
</tfoot>

</table>

<div>Text below</div>
</body>
</html>
4 changes: 3 additions & 1 deletion tests/table.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ Col A Col B
Data A1 Data B1
Data A2 Data B2
Data A3 Data B4
Total A Total B
Total A Total B

Text below