-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
(sql) 'foreign key' and 'primary key' do not highlight 'key'. #4057
Comments
It's because |
However (Note that foreign key and primary key is already in the combo list. highlight.js/src/languages/sql.js Lines 583 to 584 in 15d3b62
|
I'm trying to remember what the I think for combos we may want somethingl ike:
|
Aside from literal period, changing regular expression of $pattern is not enough to fix this problem. When the text Line 214 in 4bbf361
If the word equals to one of the keywords it returns data , however it requires exact match. So when the text is foreign key or something the returned data becomes undefined i.e. no highlights occurs there.
So we need to modify Quick fix would be the following. It looks not good, furthermore I am afraid it might affect other languages. First, change the keyword to regexp in sql.js (
Then in highligts.js
|
Describe the issue
When I write
foreign key
orprimary key
is sql language,primary
orforeign
is highlighted, howeverkey
is not.Which language seems to have the issue?
sql.
Are you using
highlight
orhighlightAuto
?highlightAll()
.Sample Code to Reproduce
Expected behavior
'key' is also highlighted.
Additional context
Even though I add the following to my script to force the word 'key' as keyword,
key
won't be highlighted. (However this addition will now highlightsforeign key
orforeign key
primary⁠ key
etc when the separator is not a single space.)I think the regexp using in COMBO does not recognize space as a part of keyword, that is the problem.
Supposing the intention of this code is to treat
foreign key
as one keyword.In my script, changing the regexp so as to include space character
solve the problem.
However I have not understand yet why
create table
is working as intended, so I am not sure this is correct fix.Also it does not highlights when I write
foreign key
using 2 spaces etc, unless I added thekey
in keyword.Though I have not understand the whole code yet, my suggestion would be the regexp at
highlight.js/src/languages/sql.js
Line 660 in 15d3b62
should be changed to recognize space as a part of keyword. (Also it need to add
key
in reserved word listhighlight.js/src/languages/sql.js
Line 99 in 15d3b62
in case there are 2 or more whitespaces
between
foreign andkey
.)The text was updated successfully, but these errors were encountered: