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
- Diff between two regions: reference= + diff-reference= with unified,
inline-annotations, and side-by-side output modes
- Tutorial step diffs: diff-step= shows current step with change
annotations relative to a previous step
- Tab groups: consecutive tab="Label" fences are wrapped in tabGroup
nodes; tab-group="id" provides cross-group sync (like Docusaurus
groupId); companions transform into framework-specific tabs
- Refactored visitor into resolveRef() helper for DRY reference
resolution across normal, diff, and diff-step modes
- Added negative lookbehinds to REF_REGEX/FILE_REGEX to prevent
matching inside diff-reference=/diff-file=
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: README.md
+83Lines changed: 83 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -298,6 +298,86 @@ Inequality and negation are kept natural: `assert x != 0` becomes `# x != 0`.
298
298
299
299
Transmutation is opt-in and runs before strip. Transmuted lines become comments and skip stripping. Unmatched lines fall through to strip as usual. Use `?noTransmute` to disable per block.
300
300
301
+
## Diff between two regions
302
+
303
+
Show a highlighted diff between two tested code states -- for migration guides, changelogs, and "what changed in v2" docs.
The primary `reference=` is the "before", `diff-reference=` is the "after". Same-file shorthand (`#v2_handler`) inherits the file from the primary. Cross-file diffs work too.
311
+
312
+
Three output modes (set globally via `diffFormat` option or per-block with `?format=`):
313
+
314
+
**`unified` (default)** -- standard diff format, `lang` set to `"diff"`:
315
+
316
+
```diff
317
+
def handler(request):
318
+
- return Response(request.body)
319
+
+ validate(request)
320
+
+ return Response(request.body, status=200)
321
+
```
322
+
323
+
**`inline-annotations`** -- Shiki `[!code ++]` / `[!code --]` markers, original language preserved:
**Step 1** renders as plain code. **Step 2** renders with `// [!code ++]` on lines added since step 1. **Step 3** shows what changed since step 2. Each block is a standalone code fence with its own prose context.
370
+
371
+
The reader sees complete, copyable code at every step -- with green/red highlights showing exactly what's new. Every step is a passing test.
372
+
373
+
`diff-step` defaults to `inline-annotations` (Shiki highlighting). Override with `?format=unified` for +/- diff output.
374
+
375
+
||`diff-reference`|`diff-step`|
376
+
|---|---|---|
377
+
| Use case | Migration guide (before/after) | Tutorial (step-by-step) |
378
+
| Output | Diff only | Full current code with change annotations |
379
+
| Default format |`unified` (+/- prefixes) |`inline-annotations` (Shiki highlights) |
380
+
301
381
## Auto-dedent
302
382
303
383
Extracted regions are automatically dedented. Common leading whitespace is removed so that code nested inside test functions or classes renders flush-left in your docs.
0 commit comments