Skip to content

Commit

Permalink
Merge branch 'master' into truncated-raw-string
Browse files Browse the repository at this point in the history
  • Loading branch information
joshgoebel authored Nov 12, 2019
2 parents e087bd3 + 980ac21 commit c469181
Show file tree
Hide file tree
Showing 15 changed files with 116 additions and 20 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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][]
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/languages/cpp.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/languages/go.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function(hljs) {
className: 'string',
variants: [
hljs.QUOTE_STRING_MODE,
{begin: '\'', end: '[^\\\\]\''},
hljs.APOS_STRING_MODE,
{begin: '`', end: '`'},
]
},
Expand Down
27 changes: 16 additions & 11 deletions src/languages/objectivec.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,32 +53,37 @@ function(hljs) {
hljs.C_BLOCK_COMMENT_MODE,
hljs.C_NUMBER_MODE,
hljs.QUOTE_STRING_MODE,
hljs.APOS_STRING_MODE,
{
className: 'string',
variants: [
{
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
]
},
{
Expand Down
13 changes: 10 additions & 3 deletions src/languages/xml.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: /</,
Expand All @@ -24,8 +28,8 @@ function(hljs) {
className: 'string',
endsParent: true,
variants: [
{begin: /"/, end: /"/},
{begin: /'/, end: /'/},
{begin: /"/, end: /"/, contains: [XML_ENTITIES]},
{begin: /'/, end: /'/, contains: [XML_ENTITIES]},
{begin: /[^\s"'=<>`]+/}
]
}
Expand All @@ -41,7 +45,9 @@ function(hljs) {
className: 'meta',
begin: '<!DOCTYPE', end: '>',
relevance: 10,
contains: [{begin: '\\[', end: '\\]'}]
contains: [
{begin: '\\[', end: '\\]'}
]
},
hljs.COMMENT(
'<!--',
Expand All @@ -54,6 +60,7 @@ function(hljs) {
begin: '<\\!\\[CDATA\\[', end: '\\]\\]>',
relevance: 10
},
XML_ENTITIES,
{
className: 'meta',
begin: /<\?xml/, end: /\?>/, relevance: 10
Expand Down
6 changes: 6 additions & 0 deletions test/markup/cpp/preprocessor.expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@
<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> x(v) ((v))</span>
<span class="hljs-meta"># <span class="hljs-meta-keyword">define</span> x(v) ((v))</span>
<span class="hljs-meta"># <span class="hljs-meta-keyword">define</span> x(v) ((v))</span>

<span class="hljs-meta">#<span class="hljs-meta-keyword">if</span> MACRO_WITH_STRING_ARG(<span class="hljs-meta-string">"hello \"world\""</span>)</span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">elif</span> MULTI_LINE <span class="hljs-comment">/* comment */</span> &lt; \
EXPRESSION</span>
<span class="hljs-keyword">int</span> bar;
<span class="hljs-meta">#<span class="hljs-meta-keyword">endif</span> <span class="hljs-comment">// comment</span></span>
6 changes: 6 additions & 0 deletions test/markup/cpp/preprocessor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ int foo(void)
#define x(v) ((v))
# define x(v) ((v))
# define x(v) ((v))

#if MACRO_WITH_STRING_ARG("hello \"world\"")
#elif MULTI_LINE /* comment */ < \
EXPRESSION
int bar;
#endif // comment
7 changes: 7 additions & 0 deletions test/markup/go/strings.expect.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">main</span><span class="hljs-params">()</span></span> {
str := <span class="hljs-string">"Hello, 世界\nHello \"world\"\nHello 'world'"</span>
char := <span class="hljs-string">'a'</span>
char2 := <span class="hljs-string">'"'</span>
char3 := <span class="hljs-string">'\\'</span>
char3 := <span class="hljs-string">'\''</span>
}
7 changes: 7 additions & 0 deletions test/markup/go/strings.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
func main() {
str := "Hello, 世界\nHello \"world\"\nHello 'world'"
char := 'a'
char2 := '"'
char3 := '\\'
char3 := '\''
}
19 changes: 19 additions & 0 deletions test/markup/objectivec/preprocessor.expect.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;iostream&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> foo 1&lt;&lt;16</span>

<span class="hljs-meta">#<span class="hljs-meta-keyword">ifdef</span> DEBUG</span>
TYPE1 foo(<span class="hljs-keyword">void</span>)
<span class="hljs-meta">#<span class="hljs-meta-keyword">else</span></span>
<span class="hljs-keyword">int</span> foo(<span class="hljs-keyword">void</span>)
<span class="hljs-meta">#<span class="hljs-meta-keyword">endif</span></span>
{ }

<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> x(v) ((v))</span>
<span class="hljs-meta"># <span class="hljs-meta-keyword">define</span> x(v) ((v))</span>
<span class="hljs-meta"># <span class="hljs-meta-keyword">define</span> x(v) ((v))</span>

<span class="hljs-meta">#<span class="hljs-meta-keyword">if</span> MACRO_WITH_STRING_ARG(<span class="hljs-meta-string">"hello \"world\""</span>)</span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">elif</span> MULTI_LINE <span class="hljs-comment">/* comment */</span> &lt; \
EXPRESSION</span>
<span class="hljs-keyword">int</span> bar;
<span class="hljs-meta">#<span class="hljs-meta-keyword">endif</span> <span class="hljs-comment">// comment</span></span>
19 changes: 19 additions & 0 deletions test/markup/objectivec/preprocessor.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <iostream>
#define foo 1<<16

#ifdef DEBUG
TYPE1 foo(void)
#else
int foo(void)
#endif
{ }

#define x(v) ((v))
# define x(v) ((v))
# define x(v) ((v))

#if MACRO_WITH_STRING_ARG("hello \"world\"")
#elif MULTI_LINE /* comment */ < \
EXPRESSION
int bar;
#endif // comment
7 changes: 7 additions & 0 deletions test/markup/objectivec/string-literals.expect.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<span class="hljs-keyword">const</span> <span class="hljs-keyword">char</span> *str = <span class="hljs-string">"Regular \"quoted\" string\n"</span>;
<span class="hljs-built_in">NSString</span> *nsstr = <span class="hljs-string">@"Obj-C \"quoted\" string\n"</span>;
<span class="hljs-keyword">char</span> c = <span class="hljs-string">'c'</span>;
<span class="hljs-keyword">char</span> c2 = <span class="hljs-string">'"'</span>;
<span class="hljs-keyword">char</span> c3 = <span class="hljs-string">'\''</span>;
<span class="hljs-keyword">char</span> c4 = <span class="hljs-string">'\n'</span>;
<span class="hljs-keyword">int</span> multibyte_char = <span class="hljs-string">'abcd'</span>;
7 changes: 7 additions & 0 deletions test/markup/objectivec/string-literals.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const char *str = "Regular \"quoted\" string\n";
NSString *nsstr = @"Obj-C \"quoted\" string\n";
char c = 'c';
char c2 = '"';
char c3 = '\'';
char c4 = '\n';
int multibyte_char = 'abcd';
4 changes: 2 additions & 2 deletions test/markup/twig/template_tags.expect.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">if</span></span> posts|<span class="hljs-keyword">length</span> %}</span><span class="xml">
</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">for</span></span> article in articles %}</span><span class="xml">
&amp;lt;div&amp;gt;
<span class="hljs-symbol">&amp;lt;</span>div<span class="hljs-symbol">&amp;gt;</span>
</span><span class="hljs-template-variable">{{ article.title|<span class="hljs-keyword">upper</span>() }}</span><span class="xml">

</span><span class="hljs-comment">{# outputs 'WELCOME' #}</span><span class="xml">
&amp;lt;/div&amp;gt;
<span class="hljs-symbol">&amp;lt;</span>/div<span class="hljs-symbol">&amp;gt;</span>
</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">endfor</span></span> %}</span><span class="xml">
</span><span class="hljs-template-tag">{% <span class="hljs-name"><span class="hljs-keyword">endif</span></span> %}</span><span class="xml">

Expand Down

0 comments on commit c469181

Please sign in to comment.