-
Notifications
You must be signed in to change notification settings - Fork 20
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
Keeping whitespaces for text nodes #23
Keeping whitespaces for text nodes #23
Conversation
<div > Text </div> | ||
|
||
<!-- Whitespaces in closing tag to the left (should not work) --> | ||
<div> Text < /div> |
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.
Cases where </
is separated by a whitespace like < /
do not work in browsers as well, so I just didn't make them work either
@@ -62,7 +62,7 @@ expression: dom | |||
], | |||
"children": [ | |||
"this is deep", | |||
"hello world" | |||
"hello world\n " |
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.
There are some cases where we get this ugly output. But this seems to be the same thing browsers do when you try to edit text nodes where they also seem to include line breaks and stuff.
Altogether I think this is the better behavior as you can just trim the result if you don't need the whitespaces.
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.
Fixes for whitespace parsing
Come on @mathiversen you marked my review comments as resolved without further comments? |
Regarding issue #22
I was fiddling a little with pest to fix this problem. Unfortunately there is no easy fix as the problem occurs when using implicit whitespaces. We can avoid the problem by using atomic rules. Unfortunately the rules we'd need to make atomic are also silent and there is no solution for atomic and silent rules yet (see pest-parser/pest#520). There is also a discussion changing whitespace handling alltogether where some people recommended just not relying on implicit whitespaces and rather doing is explicitely. With this PR I tried to do that and added some tests to verify the whitespace parsing behavior.
WHITESPACE
rule to avoid pests implicit whitespace handlingWSP
rule explicitely where is makes senseTests are all green, so I am pretty confident that everything works as expected. Unfortunately I am a pest newbie. Therfore if you could review the rewritten grammar that would be pretty great!
Thanks!