-
Notifications
You must be signed in to change notification settings - Fork 80
Syntax 0.8, part 2: Dedent multiline text to preserve content indentation #309
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
Conversation
60e6086
to
71d98b0
Compare
@zbraniecki Here's another part of the Syntax 0.8 implementation. It turned out to be quite big, and I tried to split into a series of patches to make the review easier. However, I recommend reading the combined patch first, as it features a few cleanups and more comments than the intermediate commits. This change has impact on Patterns spans, too. Previously, block patterns, i.e. patterns which start on a new line, would have their span start at the first non-blank character of the pattern: # BEFORE
message =
Value
^---- TextElement.span.start
^---- Pattern.span.start I had to change this to be able to take the first line's indentation into account when dedenting the whole pattern. Here's where the spans start right now: # AFTER
message =
Value
^---- TextElement.span.start
^-------- Pattern.span.start Let me know if you have any questions about this PR, I'll be happy to walk you though it! |
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.
The patch looks good!
I'd like to try to move away from touching the strings so much in the future and more to operate on indexes when dedenting. My suggested architecture would be to first collect start/end pointers for lines (with indents), and the leading indents as numbers.
Then calculate the min of the indents and adjust the start pointer of each line by it and only then slice the TextElements out of it.
I'm totally ok leaving it for later as its an internal change.
71d98b0
to
9a530e7
Compare
Thanks for the review.
Yeah, I think this approach is worth exploring, perhaps even for parsing other productions, not only |
Implement projectfluent/fluent@d2229f2.