Table of Contents▼
Diff
The diff component displays code changes in a familiar diff format.
It is useful for documenting updates, configuration changes, or before-and-after examples.
Basic Usage
::diff
---
lines:
- type: remove
content: "const x = 1"
- type: add
content: "const x = 2"
- type: context
content: "return x"
---
::
Result:
-const x = 1+const x = 2 return xAvailable Line Types
| Type | Prefix | Description |
|---|---|---|
add | + | Added line |
remove | - | Removed line |
context | (none) | Unchanged line |
Complete Example
::diff
---
lines:
- type: context
content: "server {"
- type: remove
content: " listen 80;"
- type: add
content: " listen 443 ssl;"
- type: context
content: "}"
---
::
Result:
server {- listen 80;+ listen 443 ssl; }Example Use Cases
The component is useful for displaying:
- Configuration changes
- Code updates
- Before-and-after comparisons
- Patch notes
- Documentation examples
Table of Contents