Skip to content

Commit

Permalink
doc: update docs/toml.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Aug 18, 2023
1 parent 9ba0641 commit 60588c5
Showing 1 changed file with 142 additions and 12 deletions.
154 changes: 142 additions & 12 deletions docs/toml.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,28 +114,33 @@ array3 = [
TOML 字符串
-----

### 多行字符串
### 基本字符串

```toml
multiLineString = """
Multi-line basic strings are surrounded
by three quotation marks on each side
and allow newlines.
"""
str1 = "I'm a string."
str2 = "You can \"quote\" me."
str3 = "Name\tJos\u00E9\nLoc\tSF."
```

### 文字字符串
### 多行基本字符串
<!--rehype:wrap-class=row-span-2-->

```toml
path = 'C:\Users\nodejs\templates'
path2 = '\\User\admin$\system32'
quoted = 'Tom "Dubs" Preston-Werner'
regex = '<\i\c*\s*>'
str1 = """
Roses are red
Violets are blue"""

str2 = """\
The quick brown \
fox jumps over \
the lazy dog.\
"""
```

用单引号括起来。不允许转义。
用行末反斜杠自动剔除非空白字符前的任何空白字符

### 多行文字字符串
<!--rehype:wrap-class=row-span-2-->

```toml
re = '''\d{2} apps is t[wo]o many'''
Expand All @@ -147,6 +152,131 @@ is preserved.
'''
```

由于没有转义,无法在由单引号包裹的字面量字符串中写入单引号

### 字面量字符串

```toml
path = 'C:\Users\nodejs\templates'
path2 = '\\User\admin$\system32'
quoted = 'Tom "Dubs" Preston-Werner'
regex = '<\i\c*\s*>'
```

用单引号括起来。不允许转义。

TOML 数字
-----

整数、浮点数、无穷甚至非数都是支持的。你可以用科学计数法甚至千分符

### 整数

```toml
int1 = +99
int2 = 42
int3 = 0
int4 = -17
```

### 十六进制带有前缀 `0x`

```toml
hex1 = 0xDEADBEEF
hex2 = 0xdeadbeef
hex3 = 0xdead_beef
```

### 八进制带有前缀 `0o`

```toml
oct1 = 0o01234567
oct2 = 0o755
```

### 二进制带有前缀 `0b`

```toml
bin1 = 0b11010110
```

### both

```toml
float7 = 6.626e-34
```

### 分隔符

```toml
float8 = 224_617.445_991_228
```

### 小数

```toml
float1 = +1.0
float2 = 3.1415
float3 = -0.01
```

### 指数

```toml
float4 = 5e+22
float5 = 1e06
float6 = -2E-2
```

### 无穷

```toml
infinite1 = inf # 正无穷
infinite2 = +inf # 正无穷
infinite3 = -inf # 负无穷
```

### 非数

```toml
not1 = nan
not2 = +nan
not3 = -nan
```

TOML 日期与时刻
-----

TOML 支持日期、时刻、日期时刻,带或者不带时区偏移

### 坐标日期时刻

```toml
odt1 = 1979-05-27T07:32:00Z
odt2 = 1979-05-27T00:32:00-07:00
odt3 = 1979-05-27T00:32:00.999999-07:00
```

### 各地日期时刻

```toml
ldt1 = 1979-05-27T07:32:00
ldt2 = 1979-05-27T00:32:00.999999
```

### 各地日期

```toml
ld1 = 1979-05-27
```

### 各地时刻

```toml
lt1 = 07:32:00
lt2 = 00:32:00.999999
```

TOML Tables
-----

Expand Down

0 comments on commit 60588c5

Please sign in to comment.