-
Notifications
You must be signed in to change notification settings - Fork 68
Modify whitespace trimming to be less hungry #36
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
base: main
Are you sure you want to change the base?
Conversation
The liquid spec is a little vague about quite how greedy whitespace
trimming should be. Currently handling here will eat any available
whitespace between tags including all newline characters
e.g.
```
(
{%- sometag -%}
)
```
will render as
```
()
```
This is ok for web markup where the whitespace is not important, but for
other document types this greedy consumption is problematic.
Ideally the ws trimming would be less hungry and only trim any whitespace
on the line containing the tag up to and including it's newline, essentially
removing any trace of the tag but leaving other lines intact rendering the above as
```
(
)
```
The change here detects whitespace as tokens as they are parsed and
discards any as indicated by the trimming directives up to an including
the first newline.
817a0f5 to
0b920bd
Compare
|
Coverage decrease reported here is not correct ^ |
|
I'll look at the coverage. Do you happen to know how this tracks the reference (Ruby) implementation of Liquid? Does it make it more or less like Ruby Liquid? (I'm planning to accept it either way, but if it makes this package act less like Ruby Liquid then it probably needs a configuration option. Otherwise an option isn't necessary and probably needlessly increases the complexity.) |
|
I've not really played with the ruby version, but will take a look and see
how it handles whitespace. I'd considered adding a config option but then
realized you can still end up with the same whitespace as before by just
not adding the extra new lines in the template, figured this was simpler
than configuration and documentation. If you'd prefer a config option I can
look into it.
Any idea why the coverage is reporting so differently?
…On Sun, May 12, 2019 at 7:46 PM Oliver Steele ***@***.***> wrote:
I'll look at the coverage.
Do you happen to know how this tracks the reference (Ruby) implementation
of Liquid? Does it make it more or less like Ruby Liquid?
(I'm planning to accept it either way, but if it makes this passage act
*less* like Ruby Liquid then it probably needs a configuration option.
Otherwise an option isn't necessary and probably needlessly increases the
complexity.)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#36 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAA7RYPRQDSRCZM7QVDTYN3PVBQZLANCNFSM4HHIORSQ>
.
|
|
Just jumping into this old thread to say that this behaviour wouldn't match the ruby liquid implementation, nor the liquidjs implementation. Both trim out newlines alongside whitespace. If merged it should certainly not be the default option. |
|
@sgargan can the whitespace control options be used to do what you want? |
The liquid spec is a little vague about quite how greedy whitespace
trimming should be. Currently handling here will eat any available
whitespace between tags including all newline characters
e.g.
will render as
This is ok for web markup where the whitespace is not important, but for
other document types this greedy consumption is problematic.
Ideally the ws trimming would be less hungry and only trim any whitespace
on the line containing the tag up to and including it's newline, essentially
removing any trace of the tag but leaving other lines intact rendering the above as
The change here detects whitespace as tokens as they are parsed and
discards any as indicated by the trimming directives up to an including
the first newline.
Checklist
make testpasses.make lintpasses.