Skip to content

Commit 50de02d

Browse files
committed
group code block options
1 parent afb3a3a commit 50de02d

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

code.mdx

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ To denote a `word` or `phrase` as code, enclose it in backticks (`).
1919

2020
### Code block
2121

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.
2323

2424
```java HelloWorld.java
2525
class HelloWorld {
@@ -39,14 +39,24 @@ class HelloWorld {
3939
```
4040
````
4141

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
4351

4452
* **String and boolean options**: Wrap with `""`, `''`, or no quotes.
4553
* **Expression options**: Wrap with `{}`, `""`, or `''`.
4654

47-
## Syntax highlighting
55+
### Syntax highlighting
4856
Enable syntax highlighting by specifying the programming language after the opening backticks of a code block.
4957

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+
5060
```java
5161
class HelloWorld {
5262
public static void main(String[] args) {
@@ -65,11 +75,7 @@ class HelloWorld {
6575
```
6676
````
6777

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
7379
Add a title after the programming language to label your code example. Titles can be any string on a single line.
7480

7581
```javascript Code Block Example
@@ -82,7 +88,7 @@ const hello = "world";
8288
```
8389
````
8490

85-
## Icon
91+
### Icon
8692
Add an icon to your code block. You can use FontAwesome icons, Lucide icons, or absolute URLs.
8793

8894
```javascript icon="square-js"
@@ -95,7 +101,7 @@ const hello = "world";
95101
```
96102
````
97103

98-
## Line Highlighting
104+
### Line Highlighting
99105
Highlight specific lines in your code blocks using `highlight` with the line numbers or ranges you want to highlight.
100106

101107
```javascript Line Highlighting Example highlight={1-2,5}
@@ -116,7 +122,7 @@ sayHello();
116122
```
117123
````
118124

119-
## Line focusing
125+
### Line focusing
120126
Focus on specific lines in your code blocks using `focus` with line numbers or ranges.
121127

122128
```javascript Line Focus Example focus={2,4-5}
@@ -137,7 +143,7 @@ sayHello();
137143
```
138144
````
139145

140-
## Show line numbers
146+
### Show line numbers
141147
Display line numbers on the left side of your code block using `lines`.
142148

143149
```javascript Show Line Numbers Example lines
@@ -158,7 +164,7 @@ sayHello();
158164
```
159165
````
160166

161-
## Expandable
167+
### Expandable
162168
Allow users to expand and collapse long code blocks using `expandable`.
163169

164170
```python Expandable Example expandable
@@ -264,7 +270,7 @@ if __name__ == "__main__":
264270
```
265271
````
266272

267-
## Wrap
273+
### Wrap
268274
Enable text wrapping for long lines using `wrap`. This prevents horizontal scrolling and makes long lines easier to read.
269275

270276
```javascript Wrap Example wrap

0 commit comments

Comments
 (0)