Skip to content

Commit

Permalink
(objectivec) Handle multibyte character literals (#2268)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidben authored and joshgoebel committed Nov 12, 2019
1 parent 0434ec2 commit 5ef8249
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Improvements:
- 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): Handle multibyte character literals (#2268) [David Benjamin][]

[Josh Goebel]: https://github.com/yyyc514
[Liam Nobel]: https://github.com/liamnobel
Expand Down
5 changes: 1 addition & 4 deletions src/languages/objectivec.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,14 @@ 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: '[^\\\\][^\']'
}
]
},
Expand Down
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';

0 comments on commit 5ef8249

Please sign in to comment.