Repository navigation
feat: default syntax dropdown to "Automatic", remove TOML option (was mapped to JSON) - #369
Open
luochen1990 wants to merge 1 commit into
Open
luochen1990 wants to merge 1 commit into
luochen1990 wants to merge 1 commit into
Conversation
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.
What
<select>on the upload form to the Automatic option (client-side highlight.js auto-detection) instead of None. Pasted code gets highlighted out of the box without any manual selection; "None" remains available for plain-text pastes.json, so selecting it silently produced JSON highlighting for TOML content.Why
With the current default, a paste is only highlighted after a manual syntax selection. Defaulting to Automatic removes that step, while manual override stays one dropdown away. A user asked for this on the v2 release thread (https://www.reddit.com/r/selfhosted/comments/14x36vs/microbin_v2_released — "maybe the option to have syntax highlighting by default set to client-side automatic?").
The TOML entry cannot be fixed by pointing it at a
tomlextension: the syntect version pinned inCargo.lock(5.3.0) does not ship a TOML syntax in its default set. Verified two ways against the 5.3.0 sources:testdata/Packagessubmodule pin isfa6b862, which predates TOML being added to sublimehq/Packages;assets/default_newlines.packdump(whatload_defaults_newlines()actually loads) contains notomlextension, while json/yaml/rust are present as controls.So a
tomlvalue would resolve to no syntax in syntect 5.3.0 and render as plain text (microbin'sfind_syntax_by_extension(...).or_else(plain_text)fallback) — removing the entry seems clearer than keeping a value that highlights TOML as JSON. TOML pastes still get some coverage under the Automatic path (the bundled highlight.js includes aninigrammar, which partially covers TOML). TOML support has since landed in syntect's unreleased master, so the option can be reintroduced after a future syntect bump.Alternatives considered
A configurable default (e.g. a
MICROBIN_DEFAULT_SYNTAXenv var wired through to the template) would be the more general solution if you prefer not to change the built-in default — happy to rework this PR in that direction. The current form keeps the diff minimal. Happy to split the two changes into separate PRs as well if you prefer.Testing
The same change has been built as part of a self-hosted instance's packaging, derived from the v2.1.4 sources: the modified template was verified to be compiled into the binary (checked the embedded template strings in the built artifact, for both the new default and the removed entry). This PR's branch passes
cargo checkagainst current master. The touched template region is byte-identical between v2.1.4 and master, so the packaging-side verification carries over.