docs(config): clarify special characters escaping (#3313)

This commit is contained in:
Kid 2021-12-13 04:51:13 +08:00 committed by GitHub
parent b4a14e3a80
commit faa9050f51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -65,7 +65,7 @@ You can use texts, variables and text groups in a format string.
#### Variable
A variable contains a `$` symbol followed by the name of the variable.
The name of a variable only contains letters, numbers and `_`.
The name of a variable can only contain letters, numbers and `_`.
For example:
@ -112,21 +112,13 @@ For example:
- When `$all` is a shortcut for `\[$a$b\] `, `($all)` will show nothing only if `$a` and `$b` are both `None`.
This works the same as `(\[$a$b\] )`.
#### Escapable characters
#### Special characters
The following symbols have special usage in a format string.
If you want to print the following symbols, you have to escape them with a backslash (`\`).
The following symbols have special usage in a format string and must be escaped: `$ \ [ ] ( )`.
- \$
- \\
- [
- ]
- (
- )
Note that `toml` has [its own escape syntax](https://github.com/toml-lang/toml#user-content-string).
It is recommended to use a literal string (`''`) in your config.
If you want to use a basic string (`""`), pay attention to escape the backslash `\`.
Note that TOML has [both basic strings and literal strings](https://toml.io/en/v1.0.0#string).
It is recommended to use a literal string (surrounded by single quotes) in your config.
If you want to use a basic string (surrounded by double quotes), you must escape the backslash itself (i.e. use `\\`).
For example, when you want to print a `$` symbol on a new line, the following configs for `format` are equivalent: