highlightjs / highlightjs/highlight.js
(C and C++) Defines treat digit separator in defines as string beginning
- Dominant language
- JavaScript
- Stars
- 25k
- Forks
- 3.8k
- Avg merge
- 11h 35m
- Merged PRs (30d)
- 3
Description
**Describe the issue**
```c
#define FOO 10'000
```
is valid code, using `'` as a digit separator. Highlight.js incorrectly treats it as a beginning of a string.
**Which language seems to have the issue?**
I tested C and C++, both get it wrong.
**Are you using `highlight` or `highlightAuto`?**
No clue. I originally noticed the issue while sending code over Discord and confirmed it again with [your demo](https://highlightjs.org/demo). I did select the language manually in both cases.
**Expected behavior**
The `'` character should be treated as part of the number.
**Additional context**
Support for this separator has been around in C++ since C++14, but it's relatively new in C, added in C23.
Contributor guide
Research direction
Start with the C and C++ language definitions and reproduce the reported `#define FOO 10'000` case in the Highlight.js demo. Done means the apostrophe is highlighted as part of the number in both languages, rather than as the beginning of a string.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cpp
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100