highlightjs / highlightjs/highlight.js
(ini) Unquoted string value with embedded period incorrectly highlighted
- Dominant language
- JavaScript
- Stars
- 25k
- Forks
- 3.8k
- Avg merge
- 11h 35m
- Merged PRs (30d)
- 3
Description
In an ini code block, unquoted string values with embedded periods are incorrectly highlighted.
I'm using highlight to specifically select the ini language, not auto-detect.
Example code:
```
UNQUOTED_STRING_WITH_EMBEDDED_PERIOD=TLSv1.2
```
Screenshot from the highlight.js demo (sorry, not a fiddle):

### Expected behavior
For comparison, here's a screenshot from the prism.js "test drive" using ini highlighting, with "correct" (expected, desired) highlighting:

(In case you're wondering, "Why don't you use prism.js, then?" The docs framework I'm using currently uses highlight.js. I'm not in control of that docs framework. I like highlight.js just fine. Thank you!)
### Analysis of highlight.js-generated HTML
Given the string value `TLSv1.2`, I can see that highlight.js groups the leading characters `TLSv1.` with the preceding equals sign (`=`), and identifies the trailing `2` as a number:
```html
UNQUOTED_STRING_WITH_EMBEDDED_PERIOD
=TLSv1.
2
```
### ini, not TOML
When I write "incorrectly highlighted", I acknowledge that I'm referring to the context of a specific ini dialect.
I understand that:
- The highlight.js ini language module is, to quote the `ini.js` comment header, for "TOML, also INI". I infer this means: TOML first, ini second.
- ini is an informal format with numerous dialects, whereas TOML is well-defined.
- In TOML, string values are (must be) quoted. That's not true of all ini dialects.
- I can imagine it would be very difficult, perhaps impossible, for a single highlight.js language module to correctly highlight TOML *and* all ini dialects.
- What I'm asking for here is, perhaps arguably, a slippery slope.
Still, I thought it was worth asking: is it possible to "fix" this "issue" - tweak the highlight.js ini language module - for this particular case, without breaking, or terribly overcomplicating, the "primary" TOML highlighting use case?
Contributor guide
Assessment
This issue has not been assessed yet.