-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
breaking: no escape at all in triple quotes
Prior to this breaking change, backslashes inside triple-quotes are treated as escape sequence. This design allowed the last string character to be " as long as it's escaped. key = """\"string value with quotes\"""" Which lead to the need of escaping backslash itself. The need of escaping backslash inside triple-quote string not only violate the HOCON spec, but also make it hard for users to hand-craft multe-line string values. For example, when writing EMQX rule-engine SQL program: """sql = SELECT tokens(payload, b'\n')""" would actually require users to write """sql = SELECT tokens(payload, b'\\n')""" this is quite counter counterintuitive. i.e. The cost of having to escape \ is probably higher than the gain of supporting escape sequence in tripe-quote strings. After this change, 4-quotes is syntax error. String ending with a " can be wrapped with """~ and ~""" instead. \# must start with a new line after """~ key = """~ "string value with quotes"~""" Also, tripe-quote as value is no longer possible (due to lack of escape sequence). Workarounds are * Use normal quotes with escape sequence * Make use of string concatenation feature: quote the preceeding characters using tripe-quotes, quote """ as "\"\"\"", then quote the following characters with triple-quote again.
- Loading branch information
Showing
6 changed files
with
98 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
## this file is to verify that 'a' and 'b' should have the same value | ||
|
||
# normal quotes with escape sequence | ||
a = "line1\nline2\"\"\"\nline3\n" | ||
|
||
# triple quotes for line1 and line3, but normal quotes for line2""" | ||
b = """line1 | ||
""" | ||
"line2\"\"\"\n" | ||
"""line3 | ||
""" | ||
|
||
# tripel quotes with indentation for line1 and line3, but normal quotes for line2""" | ||
c = """~ | ||
line1 | ||
~""" | ||
"line2\"\"\"\n" | ||
"""~ | ||
line3 | ||
~""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters