followup strformat PR. backslash escapes, tests, docs (#17700)
* Allow use of colons inside fmt
allowing colons inside fmt by replacing the format specifier delimiter lets arbitrary nim code be run within fmt expressions.
Co-authored-by: flywind <xzsflywind@gmail.com>
* formatting,documentation,backslash escapes
Adding support for evaluating expressions by special-casing parentheses causes this regression: `&"""{ "(hello)" }"""` no longer parses.
In addition, code such as &"""{(if open: '(' else: ')')}""" wouldn't work.
To enable that, as well as the use of, e.g. Table constructors inside curlies, I've added backslash escapes.
This also means that if/for/etc statements, unparenthesized, will work, if the colons are escaped, but i've left that under-documented.
It's not exactly elegant having two types of escape, but I believe it's the least bad option.
* changelog
* added json strformat test
* pulled my thumb out and wrote a parser
Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Co-authored-by: flywind <xzsflywind@gmail.com>
This commit is contained in:
parent
cae1839154
commit
0bc943ad54
3 changed files with 89 additions and 5 deletions
|
|
@ -13,6 +13,7 @@ The changes should go to changelog.md!
|
|||
|
||||
- Changed `example.foo` to take additional `bar` parameter.
|
||||
|
||||
- Added support for evaluating parenthesised expressions in strformat
|
||||
|
||||
## Language changes
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue