Skip to content

Commit f3f91bd

Browse files
authored
Update code block title options (#809)
1 parent 75531ab commit f3f91bd

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

code.mdx

Lines changed: 14 additions & 6 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 blocks
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 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.
2323

2424
```java HelloWorld.java lines icon="java"
2525
class HelloWorld {
@@ -49,10 +49,11 @@ You can add meta options to your code blocks to customize their appearance.
4949

5050
### Option syntax
5151

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 `''`.
5454

5555
### Syntax highlighting
56+
5657
Enable syntax highlighting by specifying the programming language after the opening backticks of a code block.
5758

5859
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 {
7677
````
7778

7879
### 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.
8082

8183
```javascript Code Block Example
8284
const hello = "world";
@@ -89,6 +91,7 @@ const hello = "world";
8991
````
9092

9193
### Icon
94+
9295
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.
9396

9497
```javascript icon="square-js"
@@ -102,9 +105,10 @@ const hello = "world";
102105
````
103106

104107
### Line Highlighting
108+
105109
Highlight specific lines in your code blocks using `highlight` with the line numbers or ranges you want to highlight.
106110

107-
```javascript Line Highlighting Example highlight={1-2,5}
111+
```javascript Line Highlighting Example highlight= {1-2,5}
108112
const greeting = "Hello, World!";
109113
function sayHello() {
110114
console.log(greeting);
@@ -123,9 +127,10 @@ sayHello();
123127
````
124128

125129
### Line focusing
130+
126131
Focus on specific lines in your code blocks using `focus` with line numbers or ranges.
127132

128-
```javascript Line Focus Example focus={2,4-5}
133+
```javascript Line Focus Example focus= {2,4-5}
129134
const greeting = "Hello, World!";
130135
function sayHello() {
131136
console.log(greeting);
@@ -144,6 +149,7 @@ sayHello();
144149
````
145150

146151
### Show line numbers
152+
147153
Display line numbers on the left side of your code block using `lines`.
148154

149155
```javascript Show Line Numbers Example lines
@@ -165,6 +171,7 @@ sayHello();
165171
````
166172

167173
### Expandable
174+
168175
Allow users to expand and collapse long code blocks using `expandable`.
169176

170177
```python Expandable Example expandable
@@ -271,6 +278,7 @@ if __name__ == "__main__":
271278
````
272279

273280
### Wrap
281+
274282
Enable text wrapping for long lines using `wrap`. This prevents horizontal scrolling and makes long lines easier to read.
275283

276284
```javascript Wrap Example wrap

0 commit comments

Comments
 (0)