Skip to content

Commit ce555ae

Browse files
committed
clarify diff setup
1 parent af47b10 commit ce555ae

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

code.mdx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,19 @@ sayHello();
302302

303303
### Diff
304304

305-
Add single line comments with `[!code ++]` and `[!code --]` to mark added and removed lines. You can also mark multiple lines with a single comment, such as `[!code ++:3]` or `[!code --:5]`.
305+
Show a visual diff of added or removed lines in your code blocks. Added lines are highlighted in green and removed lines are highlighted in red.
306+
307+
To create diffs, add these special comments at the end of lines in your code block:
308+
309+
- `// [!code ++]`: Mark a line as added (green highlight).
310+
- `// [!code --]`: Mark a line as removed (red highlight).
311+
312+
For multiple consecutive lines, specify the number of lines after a colon:
313+
314+
- `// [!code ++:3]`: Mark the current line plus the next two lines as added.
315+
- `// [!code --:5]`: Mark the current line plus the next four lines as removed.
316+
317+
The comment syntax must match your programming language (for example, `//` for JavaScript or `#` for Python).
306318

307319
```js Diff Example icon="code" lines
308320
const greeting = "Hello, World!"; // [!code ++]

0 commit comments

Comments
 (0)