Skip to content

Commit 60588c5

Browse files
committed
doc: update docs/toml.md
1 parent 9ba0641 commit 60588c5

File tree

1 file changed

+142
-12
lines changed

1 file changed

+142
-12
lines changed

docs/toml.md

+142-12
Original file line numberDiff line numberDiff line change
@@ -114,28 +114,33 @@ array3 = [
114114
TOML 字符串
115115
-----
116116

117-
### 多行字符串
117+
### 基本字符串
118118

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

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

129128
```toml
130-
path = 'C:\Users\nodejs\templates'
131-
path2 = '\\User\admin$\system32'
132-
quoted = 'Tom "Dubs" Preston-Werner'
133-
regex = '<\i\c*\s*>'
129+
str1 = """
130+
Roses are red
131+
Violets are blue"""
132+
133+
str2 = """\
134+
The quick brown \
135+
fox jumps over \
136+
the lazy dog.\
137+
"""
134138
```
135139

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

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

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

155+
由于没有转义,无法在由单引号包裹的字面量字符串中写入单引号
156+
157+
### 字面量字符串
158+
159+
```toml
160+
path = 'C:\Users\nodejs\templates'
161+
path2 = '\\User\admin$\system32'
162+
quoted = 'Tom "Dubs" Preston-Werner'
163+
regex = '<\i\c*\s*>'
164+
```
165+
166+
用单引号括起来。不允许转义。
167+
168+
TOML 数字
169+
-----
170+
171+
整数、浮点数、无穷甚至非数都是支持的。你可以用科学计数法甚至千分符
172+
173+
### 整数
174+
175+
```toml
176+
int1 = +99
177+
int2 = 42
178+
int3 = 0
179+
int4 = -17
180+
```
181+
182+
### 十六进制带有前缀 `0x`
183+
184+
```toml
185+
hex1 = 0xDEADBEEF
186+
hex2 = 0xdeadbeef
187+
hex3 = 0xdead_beef
188+
```
189+
190+
### 八进制带有前缀 `0o`
191+
192+
```toml
193+
oct1 = 0o01234567
194+
oct2 = 0o755
195+
```
196+
197+
### 二进制带有前缀 `0b`
198+
199+
```toml
200+
bin1 = 0b11010110
201+
```
202+
203+
### both
204+
205+
```toml
206+
float7 = 6.626e-34
207+
```
208+
209+
### 分隔符
210+
211+
```toml
212+
float8 = 224_617.445_991_228
213+
```
214+
215+
### 小数
216+
217+
```toml
218+
float1 = +1.0
219+
float2 = 3.1415
220+
float3 = -0.01
221+
```
222+
223+
### 指数
224+
225+
```toml
226+
float4 = 5e+22
227+
float5 = 1e06
228+
float6 = -2E-2
229+
```
230+
231+
### 无穷
232+
233+
```toml
234+
infinite1 = inf # 正无穷
235+
infinite2 = +inf # 正无穷
236+
infinite3 = -inf # 负无穷
237+
```
238+
239+
### 非数
240+
241+
```toml
242+
not1 = nan
243+
not2 = +nan
244+
not3 = -nan
245+
```
246+
247+
TOML 日期与时刻
248+
-----
249+
250+
TOML 支持日期、时刻、日期时刻,带或者不带时区偏移
251+
252+
### 坐标日期时刻
253+
254+
```toml
255+
odt1 = 1979-05-27T07:32:00Z
256+
odt2 = 1979-05-27T00:32:00-07:00
257+
odt3 = 1979-05-27T00:32:00.999999-07:00
258+
```
259+
260+
### 各地日期时刻
261+
262+
```toml
263+
ldt1 = 1979-05-27T07:32:00
264+
ldt2 = 1979-05-27T00:32:00.999999
265+
```
266+
267+
### 各地日期
268+
269+
```toml
270+
ld1 = 1979-05-27
271+
```
272+
273+
### 各地时刻
274+
275+
```toml
276+
lt1 = 07:32:00
277+
lt2 = 00:32:00.999999
278+
```
279+
150280
TOML Tables
151281
-----
152282

0 commit comments

Comments
 (0)