diff --git a/CHANGES.md b/CHANGES.md index dda7020b19..0ddce501b4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,7 @@ New styles: none. Improvements: +- enh(xml) support for highlighting entities (#2260) [w3suli][] - enh(gml) fix naming of keyword class (consistency fix) (#2254) [Liam Nobel][] - enh(javascript): Add support for jsdoc comments (#2245) [Milutin Kristofic][] - ehh(build) Add CI check for building a "use strict" safe rollup package from NPM builds (#2247) [Josh Goebel][] @@ -18,11 +19,16 @@ Improvements: - fix(parser): Fix merger HTML attribute quoting (#2235) [Josh Goebel][] - fix(parser): Look-ahead regex now work for end matches also (#2237) [Josh Goebel][] - fix(parser): Better errors when a language is missing (#2236) [Josh Goebel][] +- fix(go): Fix escaped character literals (#2266) [David Benjamin][] +- fix(objectivec): Fix various preprocessor highlighting issues (#2265) [David Benjamin][] +- fix(objectivec): Handle multibyte character literals (#2268) [David Benjamin][] [Josh Goebel]: https://github.com/yyyc514 [Liam Nobel]: https://github.com/liamnobel [Carl Baxter]: https://github.com/cdbax [Milutin Kristofic]: https://github.com/milutin +[w3suli]: https://github.com/w3suli +[David Benjamin]: https://github.com/davidben ## Version 9.16.2 diff --git a/src/highlight.js b/src/highlight.js index 3b34f49811..8a2d8f8855 100644 --- a/src/highlight.js +++ b/src/highlight.js @@ -642,7 +642,7 @@ https://highlightjs.org/ mode_buffer = lexeme; } } - mode = startNewMode(new_mode, lexeme); + mode = startNewMode(new_mode); if (mode.onBegin) { mode.onBegin(match.raw, mode.userState) } @@ -685,7 +685,7 @@ https://highlightjs.org/ if (end_mode.endSameAsBegin) { end_mode.starts.endRe = end_mode.endRe; } - startNewMode(end_mode.starts, ''); + startNewMode(end_mode.starts); } return origin.returnEnd ? 0 : lexeme.length; } diff --git a/src/languages/cpp.js b/src/languages/cpp.js index 8cf95f1537..5ff310fe95 100644 --- a/src/languages/cpp.js +++ b/src/languages/cpp.js @@ -61,7 +61,7 @@ function(hljs) { hljs.inherit(STRINGS, {className: 'meta-string'}), { className: 'meta-string', - begin: /<[^\n>]*>/, end: /$/, + begin: /<.*?>/, end: /$/, illegal: '\\n', }, hljs.C_LINE_COMMENT_MODE, diff --git a/src/languages/go.js b/src/languages/go.js index f473483c1b..5b6aff34d8 100644 --- a/src/languages/go.js +++ b/src/languages/go.js @@ -30,7 +30,7 @@ function(hljs) { className: 'string', variants: [ hljs.QUOTE_STRING_MODE, - {begin: '\'', end: '[^\\\\]\''}, + hljs.APOS_STRING_MODE, {begin: '`', end: '`'}, ] }, diff --git a/src/languages/objectivec.js b/src/languages/objectivec.js index 1666428f71..1a4a9fe1cc 100644 --- a/src/languages/objectivec.js +++ b/src/languages/objectivec.js @@ -53,6 +53,7 @@ function(hljs) { hljs.C_BLOCK_COMMENT_MODE, hljs.C_NUMBER_MODE, hljs.QUOTE_STRING_MODE, + hljs.APOS_STRING_MODE, { className: 'string', variants: [ @@ -60,25 +61,29 @@ function(hljs) { begin: '@"', end: '"', illegal: '\\n', contains: [hljs.BACKSLASH_ESCAPE] - }, - { - begin: '\'', end: '[^\\\\]\'', - illegal: '[^\\\\][^\']' } ] }, { className: 'meta', - begin: '#', - end: '$', + begin: /#\s*[a-z]+\b/, end: /$/, + keywords: { + 'meta-keyword': + 'if else elif endif define undef warning error line ' + + 'pragma ifdef ifndef include' + }, contains: [ + { + begin: /\\\n/, relevance: 0 + }, + hljs.inherit(hljs.QUOTE_STRING_MODE, {className: 'meta-string'}), { className: 'meta-string', - variants: [ - { begin: '\"', end: '\"' }, - { begin: '<', end: '>' } - ] - } + begin: /<.*?>/, end: /$/, + illegal: '\\n', + }, + hljs.C_LINE_COMMENT_MODE, + hljs.C_BLOCK_COMMENT_MODE ] }, { diff --git a/src/languages/xml.js b/src/languages/xml.js index 1f16442735..3eb47ed10b 100644 --- a/src/languages/xml.js +++ b/src/languages/xml.js @@ -6,6 +6,10 @@ Category: common function(hljs) { var XML_IDENT_RE = '[A-Za-z0-9\\._:-]+'; + var XML_ENTITIES = { + className: 'symbol', + begin: '&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;' + }; var TAG_INTERNALS = { endsWithParent: true, illegal: /`]+/} ] } @@ -41,7 +45,9 @@ function(hljs) { className: 'meta', begin: '', relevance: 10, - contains: [{begin: '\\[', end: '\\]'}] + contains: [ + {begin: '\\[', end: '\\]'} + ] }, hljs.COMMENT( '