Skip to content

Commit

Permalink
(chore) remove meta-keyword and meta-string in favor of nesting (#3167)
Browse files Browse the repository at this point in the history
* update dev tool list of themes
* (chore) remove meta-keyword and meta-string in favor of nesting
* Don't unnecessarily quote 'keyword' in objects
* add document and changelog

Co-authored-by: Vladimir Jimenez <allejo@me.com>
  • Loading branch information
joshgoebel and allejo committed May 14, 2021
1 parent e5e1a1d commit b54b866
Show file tree
Hide file tree
Showing 68 changed files with 208 additions and 180 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Expand Up @@ -58,6 +58,8 @@ Parser:

Grammars:

- enh(all) `.meta-keyword` => `.meta .keyword` (nested scopes) (#3167) [Josh Goebel][]
- enh(all) `.meta-string` => `.meta .string` (nested scopes) (#3167) [Josh Goebel][]
- enh(swift) add `actor` keyword (#3171) [Bradley Mackey][]
- enh(crystal) highlight variables (#3154) [Josh Goebel][]
- fix(ruby) Heredoc without interpolation (#3154) [Josh Goebel][]
Expand Down
12 changes: 10 additions & 2 deletions VERSION_11_UPGRADE.md
Expand Up @@ -3,6 +3,7 @@
- [Language Files](#language-files)
- [Language Aliases](#language-aliases)
- [Styles and CSS](#styles-and-css)
- [Grammar Scopes](#grammar-scopes)
- [Behavioral changes](#behavioral-changes)
- [API changes](#api-changes)
- [Changes to Result Data](#changes-to-result-data)
Expand Down Expand Up @@ -36,14 +37,14 @@ This would matter if you are requiring any of these files directly (via Node.js

- `htmlbars` has been removed. Use `handlebars` instead.
- `c-like` has been removed. Use `c`, `cpp`, or `arduino`.
- `sql_more` has been removed. Use `sql` instead.
- `sql_more` has been removed. Use `sql` instead or a more specific 3rd party grammar.


### Language Aliases

This would matter if you are using these aliases.

- `php3`,`php4`,`php5`, `php6`, `php7`, and `php8` havbe been removed. Use `php` instead.
- `php3`,`php4`,`php5`, `php6`, `php7`, and `php8` have been removed. Use `php` instead.
- `zsh` has been removed. Use `sh` or `bash` instead.
- `freepascal`, `lazarus`, `lpr`, and `lpm` removed. Use `delphi` instead.

Expand All @@ -61,6 +62,11 @@ hljs.registerAliases(["php3","php4","php5","php6","php7","php8"],{ languageName:
- The `.hljs` CSS selector is now further scoped. It now targets `code.hljs` (inline code) and `pre code.hljs` (code blocks). If you are using a different element you may need to update your CSS to reapply some styling.


#### Grammar Scopes

- `.meta-string` removed/deprecated. Use `.meta .string` (a nested scope) instead. See [meta-keyword][].
- `.meta-keyword` removed/deprecated. Use `.meta .keyword` (a nested scope) instead. See [meta-keyword][].

### Behavioral changes

#### API changes
Expand Down Expand Up @@ -177,3 +183,5 @@ This configuration option was deprecated in v10.5. Use a plugin or pre-render co
### Small Things

- The `regex` utility `join` has been renamed to `_eitherRewriteBackreferences` (this has always been intended for internal use only)

[meta-keyword]: https://github.com/highlightjs/highlight.js/pull/3167
6 changes: 4 additions & 2 deletions docs/css-classes-reference.rst
Expand Up @@ -80,9 +80,11 @@ in mind so a better choice (for best theme support) might possibly be ``string``
| meta | flags, modifiers, annotations, processing |
| | instructions, preprocessor directives, etc |
+--------------------------+-------------------------------------------------------------+
| meta-keyword | keyword or built-in within meta construct |
| meta keyword | a keyword inside a meta block |
| | (note this is nested, not subscoped) |
+--------------------------+-------------------------------------------------------------+
| meta-string | string within meta construct |
| meta string | a string inside a meta block |
| | (note this is nested, not subscoped) |
+--------------------------+-------------------------------------------------------------+
| **Tags, attributes, configs** |
+--------------------------+-------------------------------------------------------------+
Expand Down
2 changes: 1 addition & 1 deletion src/languages/1c.js
Expand Up @@ -450,7 +450,7 @@ export default function(hljs) {
begin: '#|&', end: '$',
keywords: {
$pattern: UNDERSCORE_IDENT_RE,
'meta-keyword': KEYWORD + METAKEYWORD
keyword: KEYWORD + METAKEYWORD
},
contains: [
COMMENTS
Expand Down
2 changes: 1 addition & 1 deletion src/languages/actionscript.js
Expand Up @@ -121,7 +121,7 @@ export default function(hljs) {
className: 'meta',
beginKeywords: 'import include',
end: /;/,
keywords: { 'meta-keyword': 'import include' }
keywords: { keyword: 'import include' }
},
{
beginKeywords: 'function',
Expand Down
6 changes: 3 additions & 3 deletions src/languages/autoit.js
Expand Up @@ -83,7 +83,7 @@ export default function(hljs) {
begin: '#',
end: '$',
keywords: {
'meta-keyword': DIRECTIVES
keyword: DIRECTIVES
},
contains: [
{
Expand All @@ -93,13 +93,13 @@ export default function(hljs) {
{
beginKeywords: 'include',
keywords: {
'meta-keyword': 'include'
keyword: 'include'
},
end: '$',
contains: [
STRING,
{
className: 'meta-string',
className: 'string',
variants: [
{
begin: '<',
Expand Down
6 changes: 3 additions & 3 deletions src/languages/c.js
Expand Up @@ -82,7 +82,7 @@ export default function(hljs) {
begin: /#\s*[a-z]+\b/,
end: /$/,
keywords: {
'meta-keyword':
keyword:
'if else elif endif define undef warning error line ' +
'pragma _Pragma ifdef ifndef include'
},
Expand All @@ -92,10 +92,10 @@ export default function(hljs) {
relevance: 0
},
hljs.inherit(STRINGS, {
className: 'meta-string'
className: 'string'
}),
{
className: 'meta-string',
className: 'string',
begin: /<.*?>/
},
C_LINE_COMMENT_MODE,
Expand Down
6 changes: 3 additions & 3 deletions src/languages/cpp.js
Expand Up @@ -76,7 +76,7 @@ export default function(hljs) {
begin: /#\s*[a-z]+\b/,
end: /$/,
keywords: {
'meta-keyword':
keyword:
'if else elif endif define undef warning error line ' +
'pragma _Pragma ifdef ifndef include'
},
Expand All @@ -86,10 +86,10 @@ export default function(hljs) {
relevance: 0
},
hljs.inherit(STRINGS, {
className: 'meta-string'
className: 'string'
}),
{
className: 'meta-string',
className: 'string',
begin: /<.*?>/
},
C_LINE_COMMENT_MODE,
Expand Down
2 changes: 1 addition & 1 deletion src/languages/crystal.js
Expand Up @@ -207,7 +207,7 @@ export default function(hljs) {
end: '\\]',
contains: [
hljs.inherit(hljs.QUOTE_STRING_MODE, {
className: 'meta-string'
className: 'string'
})
]
};
Expand Down
4 changes: 2 additions & 2 deletions src/languages/csharp.js
Expand Up @@ -329,7 +329,7 @@ export default function(hljs) {
begin: '#',
end: '$',
keywords: {
'meta-keyword': 'if else elif endif define undef warning error line region endregion pragma checksum'
keyword: 'if else elif endif define undef warning error line region endregion pragma checksum'
}
},
STRING,
Expand Down Expand Up @@ -381,7 +381,7 @@ export default function(hljs) {
excludeEnd: true,
contains: [
{
className: 'meta-string',
className: 'string',
begin: /"/,
end: /"/
}
Expand Down
10 changes: 5 additions & 5 deletions src/languages/dts.js
Expand Up @@ -45,7 +45,7 @@ export default function(hljs) {
begin: '#',
end: '$',
keywords: {
'meta-keyword': 'if else elif endif define undef ifdef ifndef'
keyword: 'if else elif endif define undef ifdef ifndef'
},
contains: [
{
Expand All @@ -56,14 +56,14 @@ export default function(hljs) {
beginKeywords: 'include',
end: '$',
keywords: {
'meta-keyword': 'include'
keyword: 'include'
},
contains: [
hljs.inherit(STRINGS, {
className: 'meta-string'
className: 'string'
}),
{
className: 'meta-string',
className: 'string',
begin: '<',
end: '>',
illegal: '\\n'
Expand All @@ -82,7 +82,7 @@ export default function(hljs) {
};

const KEYWORD = {
className: 'meta',
className: 'keyword',
begin: '/[a-z][a-z\\d-]*/'
};

Expand Down
2 changes: 1 addition & 1 deletion src/languages/gams.js
Expand Up @@ -119,7 +119,7 @@ export default function(hljs) {
returnBegin: true,
contains: [
{
className: 'meta-keyword',
className: 'keyword',
begin: '^\\$[a-z0-9]+'
}
]
Expand Down
6 changes: 3 additions & 3 deletions src/languages/gauss.js
Expand Up @@ -117,7 +117,7 @@ export default function(hljs) {
begin: '#',
end: '$',
keywords: {
'meta-keyword': 'define definecs|10 undef ifdef ifndef iflight ifdllcall ifmac ifos2win ifunix else endif lineson linesoff srcfile srcline'
keyword: 'define definecs|10 undef ifdef ifndef iflight ifdllcall ifmac ifos2win ifunix else endif lineson linesoff srcfile srcline'
},
contains: [
{
Expand All @@ -128,11 +128,11 @@ export default function(hljs) {
beginKeywords: 'include',
end: '$',
keywords: {
'meta-keyword': 'include'
keyword: 'include'
},
contains: [
{
className: 'meta-string',
className: 'string',
begin: '"',
end: '"',
illegal: '\\n'
Expand Down
2 changes: 1 addition & 1 deletion src/languages/haxe.js
Expand Up @@ -58,7 +58,7 @@ export default function(hljs) {
begin: '#',
end: '$',
keywords: {
'meta-keyword': 'if else elseif end error'
keyword: 'if else elseif end error'
}
},
{
Expand Down
4 changes: 2 additions & 2 deletions src/languages/hsp.js
Expand Up @@ -37,11 +37,11 @@ export default function(hljs) {
begin: '#',
end: '$',
keywords: {
'meta-keyword': 'addion cfunc cmd cmpopt comfunc const defcfunc deffunc define else endif enum epack func global if ifdef ifndef include modcfunc modfunc modinit modterm module pack packopt regcmd runtime undef usecom uselib'
keyword: 'addion cfunc cmd cmpopt comfunc const defcfunc deffunc define else endif enum epack func global if ifdef ifndef include modcfunc modfunc modinit modterm module pack packopt regcmd runtime undef usecom uselib'
},
contains: [
hljs.inherit(hljs.QUOTE_STRING_MODE, {
className: 'meta-string'
className: 'string'
}),
hljs.NUMBER_MODE,
hljs.C_NUMBER_MODE,
Expand Down
2 changes: 1 addition & 1 deletion src/languages/kotlin.js
Expand Up @@ -96,7 +96,7 @@ export default function(hljs) {
end: /\)/,
contains: [
hljs.inherit(STRING, {
className: 'meta-string'
className: 'string'
})
]
}
Expand Down
2 changes: 1 addition & 1 deletion src/languages/makefile.js
Expand Up @@ -55,7 +55,7 @@ export default function(hljs) {
end: /$/,
keywords: {
$pattern: /[\.\w]+/,
'meta-keyword': '.PHONY'
keyword: '.PHONY'
}
};
/* Targets */
Expand Down
2 changes: 1 addition & 1 deletion src/languages/monkey.js
Expand Up @@ -68,7 +68,7 @@ export default function(hljs) {
begin: '\\s*#',
end: '$',
keywords: {
'meta-keyword': 'if else elseif endif end then'
keyword: 'if else elseif endif end then'
}
},
{
Expand Down
6 changes: 3 additions & 3 deletions src/languages/objectivec.js
Expand Up @@ -209,7 +209,7 @@ export default function(hljs) {
begin: /#\s*[a-z]+\b/,
end: /$/,
keywords: {
'meta-keyword':
keyword:
'if else elif endif define undef warning error line ' +
'pragma ifdef ifndef include'
},
Expand All @@ -219,10 +219,10 @@ export default function(hljs) {
relevance: 0
},
hljs.inherit(hljs.QUOTE_STRING_MODE, {
className: 'meta-string'
className: 'string'
}),
{
className: 'meta-string',
className: 'string',
begin: /<.*?>/,
end: /$/,
illegal: '\\n'
Expand Down
2 changes: 1 addition & 1 deletion src/languages/openscad.js
Expand Up @@ -26,7 +26,7 @@ export default function(hljs) {
const PREPRO = {
className: 'meta',
keywords: {
'meta-keyword': 'include use'
keyword: 'include use'
},
begin: 'include|use <',
end: '>'
Expand Down
2 changes: 1 addition & 1 deletion src/languages/r.js
Expand Up @@ -108,7 +108,7 @@ export default function(hljs) {
begin: /@[a-zA-Z]+/
},
{
className: 'meta-keyword',
className: 'keyword',
begin: /\\[a-zA-Z]+/,
}
]
Expand Down
2 changes: 1 addition & 1 deletion src/languages/rust.js
Expand Up @@ -243,7 +243,7 @@ export default function(hljs) {
end: '\\]',
contains: [
{
className: 'meta-string',
className: 'string',
begin: /"/,
end: /"/
}
Expand Down
6 changes: 3 additions & 3 deletions src/languages/sqf.js
Expand Up @@ -2463,7 +2463,7 @@ export default function(hljs) {
begin: /#\s*[a-z]+\b/,
end: /$/,
keywords: {
'meta-keyword':
keyword:
'define undef ifdef ifndef else endif include'
},
contains: [
Expand All @@ -2472,10 +2472,10 @@ export default function(hljs) {
relevance: 0
},
hljs.inherit(STRINGS, {
className: 'meta-string'
className: 'string'
}),
{
className: 'meta-string',
className: 'string',
begin: /<[^\n>]*>/,
end: /$/,
illegal: '\\n'
Expand Down
2 changes: 1 addition & 1 deletion src/languages/vbnet.js
Expand Up @@ -125,7 +125,7 @@ export default function(hljs) {
begin: /[\t ]*#(const|disable|else|elseif|enable|end|externalsource|if|region)\b/,
end: /$/,
keywords: {
'meta-keyword':
keyword:
'const disable else elseif enable end externalsource if region then'
},
contains: [ COMMENT ]
Expand Down
2 changes: 1 addition & 1 deletion src/languages/verilog.js
Expand Up @@ -115,7 +115,7 @@ export default function(hljs) {
begin: '`',
end: '$',
keywords: {
'meta-keyword':
keyword:
'define __FILE__ ' +
'__LINE__ begin_keywords celldefine default_nettype define ' +
'else elsif end_keywords endcelldefine endif ifdef ifndef ' +
Expand Down

0 comments on commit b54b866

Please sign in to comment.