Skip to content

feat: add diff syntax highlighting to code blocks - #59

Merged
denolfe merged 1 commit into
mainfrom
feat/diff-highlight
Oct 8, 2026
Merged

denolfe merged 1 commit into
mainfrom
feat/diff-highlight

Conversation

@denolfe

@denolfe denolfe commented Oct 8, 2026

Copy link
Copy Markdown
Owner

Code blocks fenced as diff or patch now render with syntax highlighting. Added lines are green, removed lines are red, and changed lines (context-diff ! lines) are yellow.

```diff
-  return 'Hello, ' + name
+  return `Hello, ${name}!`
```

Key Changes

  • Bundled diff grammar
    • Ships the tree-sitter-diff v0.2.0 wasm and its highlight query under assets/parsers/diff.
    • Registers diff, with patch as an alias.
  • Diff line colors
    • New diff.plus, diff.minus, and diff.delta styles use the theme's green, red, and yellow.
  • Vendored highlight query
    • The query drops the + - < > ! line markers from its punctuation.special capture. The markers then take the color of their line.
    • OpenTUI ignores the query's priority setting. With the upstream query, the marker renders grey on a green or red line.
    • parsers-config.json points at the local query. update-parsers keeps the edit when it regenerates assets.

References / Links

Bundle the tree-sitter-diff v0.2.0 grammar with `patch` as an alias and
style added/removed/changed lines green/red/yellow.

The vendored highlights.scm drops the line markers (+ - < > !) from the
punctuation.special capture: OpenTUI ignores `priority`, so that capture
overrode the line color on the marker. parsers-config.json points at the
local query so update-parsers keeps the edit.
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown

Startup benchmark (--render test/exhaustive.md, linux-x64)

build mean ratio verdict
baseline (main@3350e91) 371.7ms ± 9.1ms —
PR 371.4ms ± 4.1ms 1.00× ✅ ok

Thresholds: warn ≥ 1.1×, fail ≥ 1.25×. Baseline built from main.

First-frame (large.md, runs=10)

metric baseline (main@3350e91) PR ratio verdict
first-frame 284.8ms 283.4ms 1.00× ✅ ok

Thresholds: warn ≥ 1.1×, fail ≥ 1.25×. Baseline built from main.

Scroll (large.md)

metric baseline (main@3350e91) PR ratio verdict
full_mount 11958.0ms 11920.0ms 1.00× ✅ ok
step_p50 27.5ms 27.5ms 1.00× ✅ ok
step_search_p50 28.2ms 28.5ms 1.01× ✅ ok
stepMatch_p50 19.5ms 19.3ms 0.99× ✅ ok
commit 159.1ms 143.5ms 0.90× ✅ ok

Thresholds: warn ≥ 1.1×, fail ≥ 1.25×. Baseline built from main.

@denolfe denolfe changed the title feat(highlight): add diff syntax highlighting to code blocks feat: add diff syntax highlighting to code blocks Oct 8, 2026
@denolfe
denolfe merged commit 714aff7 into main Oct 8, 2026
8 checks passed
@denolfe
denolfe deleted the feat/diff-highlight branch October 8, 2026 01:51
denolfe added a commit that referenced this pull request Oct 8, 2026
- feat: infer language for untagged code blocks (#60) (8726ca7)
- feat: add diff syntax highlighting to code blocks (#59) (714aff7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant