-
Notifications
You must be signed in to change notification settings - Fork 33
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
Implement @whitespace
setter.
#42
base: main
Are you sure you want to change the base?
Conversation
Currently, @kornelski , any thoughts on this or the naming / syntax questions? |
I like the
You wanted to be markup-agnostic. As such, compact may not be a safe default, as it'll mangle the |
To support collapsing of whitespace around |
Yes, me to. So I'll add that.
True. Technically, it is "compact, then trim". The suggestion was mainly to supply that the alternative does not remove all whitespace, only whitespace that is considered irrelevant. Which makes me think of one thing that is probably a bug: whitespace between words is noralized, not removed, so
Yes,
Yes, but I don't think that is a problem. Regarding
Yes, that's true (or technically, it would be enough to do a pass for this one level up in the tree). I was just thinking about existing blocks ( |
It seems fine to remove |
Sorry, I think I was a bit unclear above. This paragraph:
... refers to the beviour in a
or
The first would (currently) result in In |
I'd probably want to format like:
So in this case it'd work for me if whitespace runs containing |
As suggested in #29. A keyword `@whitespace` can be used to switch whitespace handling between the tree modes `as-is`, `compact`, and `removed`. - [x] Implment the functionality. Set default mode to `compact` and update tests. - [ ] Decide on the exact syntax; should some keyword change? Should `@ws` be allowed as an alias for `@whitespace`? Should the `removed` alternative be called `trim`? Or some other word change? - [ ] Add documentation and more tests / examples. - [ ] Anything else?
Only spaces (ascii 32), tabs, newlines and carriage returns are considered whitespace. Other variants (such as no-break space and spaces of specific width) will probably only appear in templates if they are actually wanted in output.
Hmm ... I think it would be rather strange if any sequence of whicespace and tab characters resulted in more whitespace than any such sequence that also contained a newline. |
Maybe we should instead do something like what is done in rust strings: If there is backslash (or possibly some other marker) as a last character before a newline, then the backslash, the newline and any indenting whitespace characters is removed? |
Interesting. That could work. |
As suggested in #29. A keyword
@whitespace
can be used to switch whitespace handling between the tree modesas-is
,compact
, andremoved
.compact
and update tests.@ws
be allowed as an alias for@whitespace
? Should theremoved
alternative be calledtrim
? Or some other word change?