Skip to content

Commit a824f15

Browse files
authored
docs: detailed Expressive Code attributes and examples (#391)
1 parent 431145a commit a824f15

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

docs/tutorialkit.dev/src/content/docs/guides/creating-content.mdx

+33
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,39 @@ const removed = 'This line was removed';
192192
const highlighted = 'This line is highlighted';
193193
```
194194

195+
#### Useful Expressive Code Attributes
196+
197+
- **`title`** - Sets the title of the code block.
198+
- **`frame`** - Defines the frame of the code block. Options: `"code"`, `"terminal"`, `"none"`, `"auto"`.
199+
- **`showLineNumbers`** - Displays line numbers. You can combine this with `startLineNumber=#` to begin numbering from a specific line.
200+
- **`wrap`** - Controls word wrapping. Use `preserveIndent` and `preserveIndent=false` to adjust indentation handling.
201+
202+
##### Marking Lines
203+
204+
- **`{x}`** - Marks specific lines. For example, `{6,10-18}` will mark lines 6 and 10 through 18.
205+
- **`ins`** - Marks inserted lines. Example: `ins={6,10-18}`.
206+
- **`del`** - Marks deleted lines. Example: `del={6,10-18}`.
207+
- **`{"Label":x}`** - Assigns a label to a line or range of lines. Works with `mark`, `ins`, and `del`. Example: `{"Label1":5} del={"Label2":7-8} ins={"Label3":10-12}`. If the label is long, consider placing an empty line in the code for better readability.
208+
- **`collapse={X-Y}`** - Collapses the specified lines. Example: `collapse={1-5,12-14}`.
209+
210+
##### Marking Text
211+
212+
You can highlight text using strings or regular expressions. For example:
213+
214+
````md
215+
```jsx "hello" /ye[sp]/ add=/add[12]/ del=/remove[12]/
216+
console.log(
217+
'Hello, the words yes and yep will be marked. Also add1, add2, remove1, remove2',
218+
)
219+
```
220+
````
221+
222+
```jsx "hello" /ye[sp]/ add=/add[12]/ del=/remove[12]/
223+
console.log(
224+
'Hello, the words yes and yep will be marked. Also add1, add2, remove1, remove2',
225+
)
226+
```
227+
195228
#### Importing files
196229

197230
In addition to Expressive Code features, you can import files from your code template `_files` and `_solution` folders using the file or solution shortcodes. These shortcodes insert the content of the specified file directly into your lesson content.

0 commit comments

Comments
 (0)