Closed kptdobe closed 4 years ago
Thanks for working on this! The list you added, is already in list.json
I believe.
This PR is also a bit too much: it keeps too much whitespace in the tree for a project that wants to remove superfluous whitespace.
Thanks for working on this! The list you added, is already in list.json I believe.
Not sure how I could have missed that!
This PR is also a bit too much: it keeps too much whitespace in the tree for a project that wants to remove superfluous whitespace.
The only solution I see to make that better is to check the siblings of the parent. But these are not available in the visitor
function: the only way you can know if you can trim <strong> some text </strong>
is if you know what is before and after the <strong>
node, not the text node.
I worked a bit more on it, I have added a lot of test cases (and implemented) which are not supported with current version and corrupt the DOM. I reached the point where I realised it could be a pretty complex to support any use case, especially deep nesting of inline elements. Might still fix this too.
Thanks! I've also been looking into this, sorry I didn't share that before. The tests are very useful!
Feel free to copy the tests and write a better / good solution ;)
Thanks for your help @kptdobe, released!
Fixes #19
Inline elements like
a
,span
,em
... loses there leading and trailing whitespaces while those might be are important.This PR is certainly requires some love, happy to improve the code and follow the guidelines.
Note that this changes the current behavior (see existing modified tests).