-
Notifications
You must be signed in to change notification settings - Fork 29
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: enhance collapse whitespace (#145) #160
Conversation
|
Name | Link |
---|---|
🔨 Latest commit | 8c83715 |
( | ||
collapseType === 'aggressive' && | ||
!noTrimWhitespacesInsideElements.has(tag) | ||
) | ||
collapseType === 'aggressive' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I move noTrimWhitespacesInsideElements
determination to the inside of collapseRedundantWhitespaces
method, in order to handle the edge case mentioned in #145.
node.content = collapseWhitespace(node.content, options, collapseType, node.tag); | ||
node.content = collapseWhitespace(node.content, options, collapseType, { | ||
node, | ||
prevNode, | ||
nextNode | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now the collapseRedundantWhitespaces
method can access more information about the parent node.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
TL; DR: This closes #145.
Long description:
The PR handles an edge case when a
noTrimWhitespacesInsideElement
is right next to anoTrimWhitespacesArroundElement
, and both of them have the text content surrounded by whitespace. The previous implementation is simply keeping those whitespaces, result in redundant whitespaces.cc @thewilkybarkid