@@ -371,7 +371,7 @@ export default {
371
371
372
372
``` js
373
373
export default {
374
- data () {
374
+ data () {
375
375
return {
376
376
msg: ' Highlighted!' // [!code hl]
377
377
}
@@ -381,7 +381,7 @@ export default {
381
381
382
382
## Focus in Code Blocks
383
383
384
- Adding the ` // [!code focus] ` comment on a line will focus it and blur the other parts of the code.
384
+ Adding the ` // [!code focus] ` comment on a line will focus it and blur the other parts of the code.
385
385
386
386
Additionally, you can define a number of lines to focus using ` // [!code focus:<lines>] ` .
387
387
@@ -405,17 +405,17 @@ export default {
405
405
406
406
``` js
407
407
export default {
408
- data () {
408
+ data () {
409
409
return {
410
410
msg: ' Focused!' // [!code focus]
411
411
}
412
412
}
413
413
}
414
414
```
415
415
416
- ## Colored diffs in Code Blocks
416
+ ## Colored Diffs in Code Blocks
417
417
418
- Adding the ` // [!code --] ` or ` // [!code ++] ` comments on a line will create a diff of that line, while keeping the colors of the codeblock.
418
+ Adding the ` // [!code --] ` or ` // [!code ++] ` comments on a line will create a diff of that line, while keeping the colors of the codeblock.
419
419
420
420
** Input**
421
421
@@ -447,7 +447,7 @@ export default {
447
447
}
448
448
```
449
449
450
- ## Errors and warnings
450
+ ## Errors and Warnings in Code Blocks
451
451
452
452
Adding the ` // [!code warning] ` or ` // [!code error] ` comments on a line will color it accordingly.
453
453
@@ -472,7 +472,7 @@ export default {
472
472
473
473
``` js
474
474
export default {
475
- data () {
475
+ data () {
476
476
return {
477
477
msg: ' Error' , // [!code error]
478
478
msg: ' Warning' // [!code warning]
@@ -549,11 +549,72 @@ You can also specify the language inside the braces (`{}`) like this:
549
549
<<< @/snippets/snippet.cs{c#}
550
550
551
551
<!-- with line highlighting: -->
552
+
552
553
<<< @/snippets/snippet.cs{1,2,4-6 c#}
553
554
```
554
555
555
556
This is helpful if source language cannot be inferred from your file extension.
556
557
558
+ ## Code Groups
559
+
560
+ You can group multiple code blocks like this:
561
+
562
+ ** Input**
563
+
564
+ ```` md
565
+ ::: code-group
566
+
567
+ ```js [config.js]
568
+ /**
569
+ * @type {import('vitepress').UserConfig}
570
+ */
571
+ const config = {
572
+ // ...
573
+ }
574
+
575
+ export default config
576
+ ```
577
+
578
+ ```ts [config.ts]
579
+ import type { UserConfig } from 'vitepress'
580
+
581
+ const config: UserConfig = {
582
+ // ...
583
+ }
584
+
585
+ export default config
586
+ ```
587
+
588
+ :::
589
+ ````
590
+
591
+ ** Output**
592
+
593
+ ::: code-group
594
+
595
+ ``` js [config.js]
596
+ /**
597
+ * @type {import('vitepress').UserConfig}
598
+ */
599
+ const config = {
600
+ // ...
601
+ }
602
+
603
+ export default config
604
+ ```
605
+
606
+ ``` ts [config.ts]
607
+ import type { UserConfig } from ' vitepress'
608
+
609
+ const config: UserConfig = {
610
+ // ...
611
+ }
612
+
613
+ export default config
614
+ ```
615
+
616
+ :::
617
+
557
618
## Markdown File Inclusion
558
619
559
620
You can include a markdown file in another markdown file like this:
0 commit comments