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
+14-6Lines changed: 14 additions & 6 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 blocks
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 to enable meta options. 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, like a title or icon, after the language.
23
23
24
24
```java HelloWorld.java lines icon="java"
25
25
classHelloWorld {
@@ -49,10 +49,11 @@ You can add meta options to your code blocks to customize their appearance.
49
49
50
50
### Option syntax
51
51
52
-
***String and boolean options**: Wrap with `""`, `''`, or no quotes.
53
-
***Expression options**: Wrap with `{}`, `""`, or `''`.
52
+
-**String and boolean options**: Wrap with `""`, `''`, or no quotes.
53
+
-**Expression options**: Wrap with `{}`, `""`, or `''`.
54
54
55
55
### Syntax highlighting
56
+
56
57
Enable syntax highlighting by specifying the programming language after the opening backticks of a code block.
57
58
58
59
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.
@@ -76,7 +77,8 @@ class HelloWorld {
76
77
````
77
78
78
79
### Title
79
-
Add a title after the programming language to label your code example. Titles can be any string on a single line.
80
+
81
+
Add a title to label your code example. Use `title="Your title"` or a string on a single line.
80
82
81
83
```javascript Code Block Example
82
84
consthello="world";
@@ -89,6 +91,7 @@ const hello = "world";
89
91
````
90
92
91
93
### Icon
94
+
92
95
Add an icon to your code block. You can use [FontAwesome](https://fontawesome.com/icons) icons, [Lucide](https://lucide.dev/icons/) icons, or absolute URLs.
93
96
94
97
```javascript icon="square-js"
@@ -102,9 +105,10 @@ const hello = "world";
102
105
````
103
106
104
107
### Line Highlighting
108
+
105
109
Highlight specific lines in your code blocks using `highlight` with the line numbers or ranges you want to highlight.
106
110
107
-
```javascript Line Highlighting Example highlight={1-2,5}
111
+
```javascript Line Highlighting Example highlight={1-2,5}
108
112
constgreeting="Hello, World!";
109
113
functionsayHello() {
110
114
console.log(greeting);
@@ -123,9 +127,10 @@ sayHello();
123
127
````
124
128
125
129
### Line focusing
130
+
126
131
Focus on specific lines in your code blocks using `focus` with line numbers or ranges.
127
132
128
-
```javascript Line Focus Example focus={2,4-5}
133
+
```javascript Line Focus Example focus={2,4-5}
129
134
constgreeting="Hello, World!";
130
135
functionsayHello() {
131
136
console.log(greeting);
@@ -144,6 +149,7 @@ sayHello();
144
149
````
145
150
146
151
### Show line numbers
152
+
147
153
Display line numbers on the left side of your code block using `lines`.
148
154
149
155
```javascript Show Line Numbers Example lines
@@ -165,6 +171,7 @@ sayHello();
165
171
````
166
172
167
173
### Expandable
174
+
168
175
Allow users to expand and collapse long code blocks using `expandable`.
169
176
170
177
```python Expandable Example expandable
@@ -271,6 +278,7 @@ if __name__ == "__main__":
271
278
````
272
279
273
280
### Wrap
281
+
274
282
Enable text wrapping for long lines using `wrap`. This prevents horizontal scrolling and makes long lines easier to read.
0 commit comments