Detect JSONL as well as JSON for syntax highlight - #407
Merged
Conversation
Contributor
There was a problem hiding this comment.
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. |
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` |  |  |  |  | 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 [@​scudette](https://github.com/scudette) in [#​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 [@​ssgelm](https://github.com/ssgelm) in [#​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=-->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.