-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(cpp) Keywords followed by parens are treated as built_in
#3980
Comments
We'd need a list of all false positives - keywords that are often followed by |
I think I got a list of all such keywords:
You can check them here: It is seen that some of them are working fine while others are getting stuck. Looking for Suggestions !!! |
This is allowing them(switch, decltype, while etc) to work fine. Should we add all such keywords here or are there any better solution for this |
Yep we need to add guards for all the false positives. |
Oops, I was planning to check for false positives, but have been prioritising a presentation. Thanks for taking the initiative, @akhtarmdsaad! Your list looks good. The following are additional words that may need to be guarded against too. // declarations
requires
explicit
// compound operators
bitand_eq
bitor_eq
xor_eq
// binary operators
and
or
bitand
bitor
xor
not_eq
// unary operators
not
compl
co_await
co_return
co_yield |
Here's confirmation. Looks like I missed |
Thanks @cjdb for correcting my list. After checking the |
Good catch! It's at this point that I'm beginning to wonder if it's possible to get highlight.js to tap into Clang tooling when that's made available. I'm expecting a "no", but am hoping wasm might be able to offer an in-road. |
Same for the below keywords too: Working fine for
|
Oh, we'll need to add |
|
Here is the list of keywords that are added:
|
const FUNCTION_DISPATCH = {
className:"function.dispatch",
keywords: CPP_KEYWORDS, -----------------------> Added this line
relevance: 0,
begin: regex.concat(
/\b/,
hljs.IDENT_RE,
regex.lookahead(/(<[^<>]+>|)\s*\(/)
),
}; The result looks like this: Although the highlighting goes perfect but the keywords are placed inside |
Describe the issue
Keywords, such as
static_assert
,sizeof
, etc. are typically followed by parentheses.static_assert;
will be highlighted as if it's a keyword, butstatic_assert(true);
is highlighted as a built_in.Which language seems to have the issue?
Are you using
highlight
orhighlightAuto
?highlight
, I think?Sample Code to Reproduce
In reveal.js, with a freshly-downloaded hljs, add the following:
Expected behavior
Keywords continue to use their keyword colour when followed by parens.
The text was updated successfully, but these errors were encountered: