Skip to content

Commit

Permalink
Don’t remove top level <br> tags that separate text nodes (Apple cale…
Browse files Browse the repository at this point in the history
…ndar alerts)
  • Loading branch information
bengotow committed May 24, 2020
1 parent 4c6ab52 commit df26391
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app/src/services/quoted-html-transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,13 @@ class QuotedHTMLTransformer {
return;
}

// Find back-to-back <br><br> at the top level and de-duplicate them
const { children } = doc.body;
// Find back-to-back <br><br> at the top level and de-duplicate them. Note that
// some emails contain TEXT<br>TEXT<br>TEXT, so the only ELEMENT children may be the <brs>
const nodes = doc.body.childNodes;
const extraTailBrTags = [];
for (let i = children.length - 1; i >= 0; i--) {
const curr = children[i];
const next = children[i - 1];
for (let i = nodes.length - 1; i >= 0; i--) {
const curr = nodes[i];
const next = nodes[i - 1];
if (curr && curr.nodeName === 'BR' && next && next.nodeName === 'BR') {
extraTailBrTags.push(curr);
} else {
Expand Down

0 comments on commit df26391

Please sign in to comment.