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
+17-5Lines changed: 17 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -302,7 +302,19 @@ sayHello();
302
302
303
303
### Diff
304
304
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).
0 commit comments