Skip to content

Commit d7dd909

Browse files
docs($markdown): add missing examples for line highlighting (fix #2473) (#2477)
1 parent d91beca commit d7dd909

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

packages/docs/docs/guide/markdown.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,46 @@ export default {
275275
}
276276
```
277277

278+
In addition to a single line, you can also specify multiple single lines, line ranges, or both.
279+
280+
- Line ranges: e.g. `{5-8}`, `{3-10}`, `{10-17}`
281+
- Multiple single lines: e.g. `{4,7,9}`
282+
- Line ranges and single lines: e.g. `{4,7-13,16,23-27,40}`
283+
284+
**Input**
285+
286+
````
287+
``` js{1,4,6-7}
288+
export default { // Highlighted
289+
data () {
290+
return {
291+
msg: `Highlighted!
292+
This line isn't highlighted,
293+
but this and the next 2 are.`,
294+
motd: 'VuePress is awesome',
295+
lorem: 'ipsum',
296+
}
297+
}
298+
}
299+
```
300+
````
301+
302+
**Output**
303+
304+
``` js{1,4,6-8}
305+
export default { // Highlighted
306+
data () {
307+
return {
308+
msg: `Highlighted!
309+
This line isn't highlighted,
310+
but this and the next 2 are.`,
311+
motd: 'VuePress is awesome',
312+
lorem: 'ipsum',
313+
}
314+
}
315+
}
316+
```
317+
278318
## Line Numbers
279319

280320
You can enable line numbers for each code blocks via config:

packages/docs/docs/zh/guide/markdown.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,46 @@ export default {
270270
}
271271
```
272272

273+
除了单行以外,你也可指定多行,行数区间,或是两者都指定。
274+
275+
- 行数区间: 例如 `{5-8}`, `{3-10}`, `{10-17}`
276+
- 多个单行: 例如 `{4,7,9}`
277+
- 行数区间与多个单行: 例如 `{4,7-13,16,23-27,40}`
278+
279+
**Input**
280+
281+
````
282+
``` js{1,4,6-7}
283+
export default { // Highlighted
284+
data () {
285+
return {
286+
msg: `Highlighted!
287+
This line isn't highlighted,
288+
but this and the next 2 are.`,
289+
motd: 'VuePress is awesome',
290+
lorem: 'ipsum',
291+
}
292+
}
293+
}
294+
```
295+
````
296+
297+
**Output**
298+
299+
``` js{1,4,6-8}
300+
export default { // Highlighted
301+
data () {
302+
return {
303+
msg: `Highlighted!
304+
This line isn't highlighted,
305+
but this and the next 2 are.`,
306+
motd: 'VuePress is awesome',
307+
lorem: 'ipsum',
308+
}
309+
}
310+
}
311+
```
312+
273313
## 行号
274314

275315
你可以通过配置来为每个代码块显示行号:

0 commit comments

Comments
 (0)