You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: code.mdx
+20-14Lines changed: 20 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ To denote a `word` or `phrase` as code, enclose it in backticks (`).
19
19
20
20
### Code block
21
21
22
-
Use [fenced code blocks](https://www.markdownguide.org/extended-syntax/#fenced-code-blocks) by enclosing code in three backticks. Specify the programming language for syntax highlighting, and add any meta options after the language.
22
+
Use [fenced code blocks](https://www.markdownguide.org/extended-syntax/#fenced-code-blocks) by enclosing code in three backticks. Specify the programming language for syntax highlighting and to enable meta options. Add any meta options after the language.
23
23
24
24
```java HelloWorld.java
25
25
classHelloWorld {
@@ -39,14 +39,24 @@ class HelloWorld {
39
39
```
40
40
````
41
41
42
-
#### Option syntax
42
+
## Code block options
43
+
44
+
You can add meta options to your code blocks to customize their appearance.
45
+
46
+
<Note>
47
+
You must specify a programming language for a code block before adding any other meta options.
48
+
</Note>
49
+
50
+
### Option syntax
43
51
44
52
***String and boolean options**: Wrap with `""`, `''`, or no quotes.
45
53
***Expression options**: Wrap with `{}`, `""`, or `''`.
46
54
47
-
## Syntax highlighting
55
+
###Syntax highlighting
48
56
Enable syntax highlighting by specifying the programming language after the opening backticks of a code block.
49
57
58
+
We use Shiki for syntax highlighting and support all available languages. See the full list of [languages](https://shiki.style/languages) in Shiki's documentation.
59
+
50
60
```java
51
61
classHelloWorld {
52
62
publicstaticvoidmain(String[] args) {
@@ -65,11 +75,7 @@ class HelloWorld {
65
75
```
66
76
````
67
77
68
-
### Languages
69
-
70
-
We use Shiki for syntax highlighting and support all available languages. See the full list of [languages](https://shiki.style/languages) in Shiki's documentation.
71
-
72
-
## Title
78
+
### Title
73
79
Add a title after the programming language to label your code example. Titles can be any string on a single line.
74
80
75
81
```javascript Code Block Example
@@ -82,7 +88,7 @@ const hello = "world";
82
88
```
83
89
````
84
90
85
-
## Icon
91
+
###Icon
86
92
Add an icon to your code block. You can use FontAwesome icons, Lucide icons, or absolute URLs.
87
93
88
94
```javascript icon="square-js"
@@ -95,7 +101,7 @@ const hello = "world";
95
101
```
96
102
````
97
103
98
-
## Line Highlighting
104
+
###Line Highlighting
99
105
Highlight specific lines in your code blocks using `highlight` with the line numbers or ranges you want to highlight.
100
106
101
107
```javascript Line Highlighting Example highlight={1-2,5}
@@ -116,7 +122,7 @@ sayHello();
116
122
```
117
123
````
118
124
119
-
## Line focusing
125
+
###Line focusing
120
126
Focus on specific lines in your code blocks using `focus` with line numbers or ranges.
121
127
122
128
```javascript Line Focus Example focus={2,4-5}
@@ -137,7 +143,7 @@ sayHello();
137
143
```
138
144
````
139
145
140
-
## Show line numbers
146
+
###Show line numbers
141
147
Display line numbers on the left side of your code block using `lines`.
142
148
143
149
```javascript Show Line Numbers Example lines
@@ -158,7 +164,7 @@ sayHello();
158
164
```
159
165
````
160
166
161
-
## Expandable
167
+
###Expandable
162
168
Allow users to expand and collapse long code blocks using `expandable`.
163
169
164
170
```python Expandable Example expandable
@@ -264,7 +270,7 @@ if __name__ == "__main__":
264
270
```
265
271
````
266
272
267
-
## Wrap
273
+
###Wrap
268
274
Enable text wrapping for long lines using `wrap`. This prevents horizontal scrolling and makes long lines easier to read.
0 commit comments