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

fix: email new line by skipping extra div #13503

Merged
merged 3 commits into from
Dec 16, 2022
Merged
Changes from 2 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
4 changes: 4 additions & 0 deletions src/libs/SelectionScraper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ const replaceNodes = (dom) => {
if (htmlEngineUtils.isCommentTag(dom.attribs[tagAttribute])) {
dom.children.push(new Element('br', {}));
}
} else if (dom.name === 'div' && dom.children.length === 1 && dom.children[0].type !== 'text') {
// We are excluding divs that have only one child and no text nodes and don't have a tagAttribute.
// This is due to the fact that these divs are meaningless to us and are interfering with the HTML to Markdown conversion process.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and don't have a tagAttribute

Is that true? I can't see which condition this is referring to

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else condition

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slight re-wording:

We are excluding divs that have only one child and no text nodes and don't have a tagAttribute to prevent additional newlines from being added in the HTML to Markdown conversion process.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just think this is the case we catch but can be another case also not only a new line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Julesssss but yes we just explain what we have now so i update the comment

return replaceNodes(dom.children[0]);
}

// We need to preserve href attribute in order to copy links.
Expand Down