highlightjs / highlight.js

JavaScript syntax highlighter with language auto-detection and zero dependencies.
https://highlightjs.org/
BSD 3-Clause "New" or "Revised" License
23.3k stars 3.52k forks source link

(C) C23's digit separators are highlighted incorrectly #4054

Open Melkor-1 opened 1 month ago

Melkor-1 commented 1 month ago

Describe the issue

C23 has added digit specifiers to the language (', just like C++). They are not highlighted correctly in the code. It seems as if the engine treats it as the start of a string/character

Which language seems to have the issue? c

Are you using highlight or highlightAuto?

Whichever one StackExchange uses.

Sample Code to Reproduce

#define _POSIX_C_SOURCE 200'809L
#define _XOPEN_SOURCE   700

Expected behavior

It should recognize it as a digit separator instead of a character or a string opening quote.

Additional context

This was found at this code review post: https://codereview.stackexchange.com/revisions/292149/6

And it was fixed by such a hack:

#define _POSIX_C_SOURCE 200'809L // '
joshgoebel commented 1 month ago

Does our C++ grammar properly support this already. If so might be an easy port.