-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(chore) Create
c-like
and c/cpp depend on that now
- chore(parser): effectively rename `cpp.js` to `c-like.js` [Josh Goebel][] - chore(parser): create new `c.js` (C), depends on `c-like` now [Josh Goebel][] - chore(parser): create new `cpp.js` (C), depends on `c-like` now [Josh Goebel][] - This will allow us to clean up C/C++ in the future without another breaking change by getting this require change out of the way early. (#2146)
- Loading branch information
1 parent
cf1349c
commit ff66769
Showing
5 changed files
with
61 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
/* | ||
Language: C++ | ||
Language: C-like foundation grammar for C/C++ grammars | ||
Author: Ivan Sagalaev <[email protected]> | ||
Contributors: Evgeny Stepanischev <[email protected]>, Zaven Muradyan <[email protected]>, Roel Deckers <[email protected]>, Sam Wu <[email protected]>, Jordi Petit <[email protected]>, Pieter Vantorre <[email protected]>, Google Inc. (David Benjamin) <[email protected]> | ||
Category: common, system | ||
Website: https://isocpp.org | ||
*/ | ||
|
||
/* In the future the intention is to split out the C/C++ grammars distinctly | ||
since they are separate languages. They will likely share a common foundation | ||
though, and this file sets the groundwork for that - so that we get the breaking | ||
change in v10 and don't have to change the requirements again later. | ||
See: https://github.com/highlightjs/highlight.js/issues/2146 | ||
*/ | ||
|
||
function(hljs) { | ||
|
@@ -192,6 +199,9 @@ function(hljs) { | |
return { | ||
aliases: ['c', 'cc', 'h', 'c++', 'h++', 'hpp', 'hh', 'hxx', 'cxx'], | ||
keywords: CPP_KEYWORDS, | ||
// the base c-like language will NEVER be auto-detected, rather the | ||
// derivitives: c, c++, arduino turn auto-detect back on for themselves | ||
disableAutodetect: true, | ||
illegal: '</', | ||
contains: [].concat( | ||
EXPRESSION_CONTEXT, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
Language: C | ||
Category: common, system | ||
Website: https://en.wikipedia.org/wiki/C_(programming_language) | ||
Requires: c-like.js | ||
*/ | ||
|
||
function(hljs) { | ||
|
||
var lang = hljs.getLanguage('c-like').rawDefinition(); | ||
// Until C is actually different than C++ there is no reason to auto-detect C | ||
// as it's own language since it would just fail auto-detect testing or | ||
// simply match with C++. | ||
// | ||
// See further comments in c-like.js. | ||
|
||
// lang.disableAutodetect = false; | ||
return lang; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
Language: C++ | ||
Category: common, system | ||
Website: https://isocpp.org | ||
Requires: c-like.js | ||
*/ | ||
|
||
function(hljs) { | ||
|
||
var lang = hljs.getLanguage('c-like').rawDefinition(); | ||
// return auto-detection back on | ||
lang.disableAutodetect = false; | ||
return lang; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters