Skip to content

Commit 2fcf753

Browse files
dks333ethanpalm
andauthored
add diff in code block (#823)
* add diff in code block * Update code.mdx Co-authored-by: Ethan Palm <[email protected]> --------- Co-authored-by: Ethan Palm <[email protected]>
1 parent 0406ff0 commit 2fcf753

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

code.mdx

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ You can add meta options to your code blocks to customize their appearance.
5858

5959
Enable syntax highlighting by specifying the programming language after the opening backticks of a code block.
6060

61-
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.
61+
We use [Shiki](https://shiki.style/) for syntax highlighting and support all available languages. See the full list of [languages](https://shiki.style/languages) in Shiki's documentation.
6262

6363
```java
6464
class HelloWorld {
@@ -300,3 +300,27 @@ function sayHello() {
300300
sayHello();
301301
```
302302
````
303+
304+
### Diff
305+
306+
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]`.
307+
308+
```js Diff Example icon="code" lines
309+
const greeting = "Hello, World!"; // [!code ++]
310+
function sayHello() {
311+
console.log("Hello, World!"); // [!code --]
312+
console.log(greeting); // [!code ++]
313+
}
314+
sayHello();
315+
```
316+
317+
````mdx
318+
```js Diff Example icon="code" lines
319+
const greeting = "Hello, World!"; // [\!code ++]
320+
function sayHello() {
321+
console.log("Hello, World!"); // [\!code --]
322+
console.log(greeting); // [\!code ++]
323+
}
324+
sayHello();
325+
```
326+
````

0 commit comments

Comments
 (0)