Skip to content

Detect JSONL as well as JSON for syntax highlight - #407

Merged
walles merged 4 commits into
walles:masterfrom
scudette:jsonl
May 9, 2026
Merged

Detect JSONL as well as JSON for syntax highlight#407
walles merged 4 commits into
walles:masterfrom
scudette:jsonl

Conversation

@scudette

@scudette scudette commented May 6, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds JSONL detection to the reader’s automatic syntax-highlighting so newline-delimited JSON inputs can be highlighted using the JSON lexer.

Changes:

  • Extend highlight autodetection to treat JSONL-like buffers as JSON for Chroma highlighting.
  • Add a JSONL sample file under sample-files/.
  • Add a unit test for the new JSON/JSONL detection helper.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
sample-files/jsonl.jsonl Adds a small JSONL fixture used to validate detection/highlighting behavior.
internal/reader/highlight.go Introduces isJsonOrJsonl() and uses it to select the JSON lexer when appropriate.
internal/reader/highlight_test.go Adds a test exercising JSON vs JSONL detection using the new sample file.

Comment thread internal/reader/highlight.go
Comment thread internal/reader/highlight_test.go
@walles
walles merged commit e25c5ba into walles:master May 9, 2026
6 checks passed
@walles

walles commented May 9, 2026

Copy link
Copy Markdown
Owner

Thanks @scudette!

alecthomas pushed a commit to alecthomas/chroma that referenced this pull request May 9, 2026
### Description
This PR adds support for JSON Lines (JSONL) to the existing JSON lexer.

Because the existing JSON lexer already handles repeating objects
natively, this implementation simply maps the \`jsonl\` file extension,
alias, and mime type to the \`JSON\` lexer configuration without needing
any underlying state machine changes.

Inspired by walles/moor#407.

### Changes
* **Alias added:** \`jsonl\`
* **File extension added:** \`*.jsonl\`
* **MIME type added:** \`application/jsonl\`
* **Tests:** Added \`jsonl.actual\` and \`jsonl.expected\` validation
files to ensure tokens are correctly extracted across newlines in
\`.jsonl\` files.

### Testing
Ran \`go test ./lexers -run TestLexers\` locally to verify that JSON
Lines objects format accurately and consistently.
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request May 11, 2026
…2.13.1

This MR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Adoption](https://docs.renovatebot.com/merge-confidence/) | [Passing](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|---|---|
| [go:github.com/walles/moor/v2/cmd/moor](https://github.com/walles/moor) | `2.12.3` → `2.13.1` | ![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fwalles%2fmoor%2fv2%2fcmd%2fmoor/v2.13.1?slim=true) | ![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fwalles%2fmoor%2fv2%2fcmd%2fmoor/v2.13.1?slim=true) | ![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fwalles%2fmoor%2fv2%2fcmd%2fmoor/v2.12.3/v2.13.1?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fwalles%2fmoor%2fv2%2fcmd%2fmoor/v2.12.3/v2.13.1?slim=true) |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>walles/moor (go:github.com/walles/moor/v2/cmd/moor)</summary>

### [`v2.13.1`](https://github.com/walles/moor/releases/tag/v2.13.1): : Performance improvements for searching

[Compare Source](walles/moor@v2.13.0...v2.13.1)

Performance when searching and scrolling sideways to search hits has
been significantly improved. Hits are now also centered on the screen
when scrolling sideways.

Also in this release:

- Fix a goroutine leak and limit CPU usage when searching
- Detect JSONL files and apply JSON syntax highlighting, thanks [@&#8203;scudette](https://github.com/scudette) in [#&#8203;407](walles/moor#407)!

### [`v2.13.0`](https://github.com/walles/moor/releases/tag/v2.13.0): : File reloading improvements

[Compare Source](walles/moor@v2.12.3...v2.13.0)

In this release, moor now automatically detects if a file gets
truncated/shrunk or completely rewritten and reloads it appropriately.
Also, you can now press `r` at any time to manually reload the current
file.

Additionally, the man page got minor touchups, thanks [@&#8203;ssgelm](https://github.com/ssgelm) in [#&#8203;405](walles/moor#405)!

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xNjkuNCIsInVwZGF0ZWRJblZlciI6IjQzLjE2OS40IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiLCJhdXRvbWF0aW9uOmJvdC1hdXRob3JlZCIsImRlcGVuZGVuY3ktdHlwZTo6bWlub3IiXX0=-->
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.

3 participants