-
Notifications
You must be signed in to change notification settings - Fork 46
Require message body to be indented #32
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
|
@Pike, @zbraniecki -- this is an early version of the change I'd like to propose. @Pike will recognize ideas from our brainstorming session a few week ago. I think there are still some things missing here. One is handling completely blank lines. I'd like to get your feedback at this stage. Let me know what you think, thanks! |
Does it remove the ability to use quoted patterns in order to get significant trailing/leading white spaces? |
Just a little bit. In #22 I'd like to define all backslash-escapes and allow escaping leading and trailing whitespace either explicitly or through Unicode escapes. Do you think it's a common enough use-case that we should give it better support? |
|
Idk, we can ask @Flod. But I know that from the readability principle perspective: is a very clear way to say - I want |
|
I'll look into the actual diff here in more detail, but regarding the leading/trailing whitespace, just one \ should suffice? would easily denote " Value". Trailing whitespace is more tricky, as it's hard to distinguish "" from "\ ". That said, on this particular aspect, my experience is that we rarely see leading or trailing whitespace in strings. In particular, if we would, we might want to make whitespace around |
|
is there any particular reason to remove the quote-delimited strings? If it's just for simplicity, we could ensure we don't lock ourselves out of this solution and keep it in a sleeve in case a use case pops up later. |
|
I would be OK forbidding quoted strings in placeables: |
|
While I agree that First thought when put in front of this: are these quotes going to show up in the product? Should I replace these with prettier/proper double quotes? If the expectation is for localizers to work in tools, and for those who don't to be smart enough to be familiar with the syntax, I think that's a good choice. Escaping the leading whitespace seems more confusing to me. Also reminds me of multiline properties, even if it's leading and not trailing. P.S. sadly flod was taken when I signed up to GH, so you pinged a random inactive user, but I'm watching this project these days |
|
On the actual diff, there are a few edgecases still. AFAICT, there can be one empty line, but only one at a time in a message body? is ok, but isn't? Also, there are a few cases where EOF is probably OK instead of NL? I personally would also like to see While thinking of EOF, I also noticed that the grammar doesn't allow for leading whitespace-only lines. |
|
I updated the PR to address @Pike's feedback. (Thanks for the help!) I kept the quoted strings, but with a change to their semantics: they can only be simple strings right now which means they must not contain any placeables. They can be used as values to The latter is useful for providing a way to unambiguously encode leading and trailing white-space into a value: Leading and trailing white-space will be vary rare—in fact we should actively discourage it. This approach makes it possible but doesn't optimize the syntax for it in any way. |
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.
As I sat next to stas while he typed this, I'm in favor of this in principle, and didn't find anything to nag about on the details of the grammar.
Fix projectfluent#12, projectfluent#17, projectfluent#18. With this change, the entire body of a message must be indented. This makes error recovery very easy: finding the next message definition is as simple as finding the next identifier with no indentation. It also opens up a number of opportunities: we can remove the `|` syntax for multiline blocks of text and allow line breaks inside of placeables safely. The change also allows the value to be defined on a new line, making the following examples equivalent: lipsum = Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi pellentesque congue metus, non mattis sem faucibus sit amet. lipsum = Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi pellentesque congue metus, non mattis sem faucibus sit amet. Lastly, quoted patterns are only available inside of placeables, cannot contain aother placeables and cannot be used directly as values. The exact semantics of \ escapes will be defined in projectfluent#22.
Fix #12, #17, #18.
With this change, the entire body of a message needs to indented. This makes
error recovery very easy: finding the next message definition is as simple as
finding the next identifier with no indentation.
It also opens up a number of opportunities: we can remove the
|syntax formultiline blocks of text and allow line breaks inside of placeables safely.
The PR also allows the value to be defined on a new line, making the
following examples equivalent:
I hope this will help when attributes are present:
Lastly, quoted patterns are only available inside of placeables and cannot be
used directly as values.
The exact semantics of
\escapes will be defined in #22.