-
-
Notifications
You must be signed in to change notification settings - Fork 203
Use tokenizer to parse label quotes into tokens #170
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
|
How will it work for yaml if you need multiple args with or without quotes? Should backticks be used in yaml in general do you think? |
| } | ||
|
|
||
| if strings.ContainsAny(key, ` "'`) { | ||
| if strings.ContainsAny(key, "\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.
@francislavoie
Updated this logic, to make use of backticks whenever it can to improve readability
| without_spaces abcd | ||
| multiple "a b c d" abcd | ||
| back `{"some":"json"}` | ||
| escaped `a"b` |
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.
@francislavoie
This is now a case, where we would not preserve the original quotes used to declare the token.
But the generator knows backticks generate a more readable string because it doesn't require double quote scaping.
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.
@francislavoie
What do you think?
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.
I guess I'm indifferent? Feels like an edgecase that won't come up so often. 🤷♂️
|
I think you can chose between double-quotes or backticks. mylabel: "\"arg 1\" \"arg 2\""
mylabel: "`arg 1` `arg 2`"
mylabel: '"arg 1" "arg 2"'
mylabel: "`arg\n1` `arg 2`"
mylabel: arg1 arg2I'm not sure about these ones: mylabel: |
"arg 1" "arg 2"
mylabel: |
`line1
line2` otherarg |
|
Ah right, single quotes helps the situation 👍 Is |
|
Wow, according to https://yaml-online-parser.appspot.com/ that works very well. I'm surprised! But this isn't: mylabel: "arg1" "arg2" |
|
@francislavoie |
|
Yeah, multiline backticks works: {
"apps": {
"http": {
"servers": {
"srv0": {
"listen": [
":80"
],
"routes": [
{
"match": [
{
"path": [
"/"
]
}
],
"handle": [
{
"body": "\n\u003chtml\u003e\n....\n\u003c/html\u003e\n",
"handler": "static_response"
}
]
}
]
}
}
}
}
}You can check easily with The |
3d15482 to
02ac7f1
Compare
02ac7f1 to
6d004a0
Compare
Improvements for #168