Skip to content

Commit 31f7444

Browse files
codingthatewwwin
authored andcommitted
fix(ex) ?' character literal should not break highlighting (#4241)
1 parent 60764a7 commit 31f7444

File tree

5 files changed

+14
-0
lines changed

5 files changed

+14
-0
lines changed

CHANGES.md

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Core Grammars:
1010
- fix(javascript) correctly highlight 'for await' again [wolfgang42][]
1111
- enh(csp) add missing directives / keywords from MDN (7 more) [Max Liashuk][]
1212
- enh(ada) add new `parallel` keyword, allow `[]` for Ada 2022 [Max Reznik][]
13+
- fix(ex) adds support for `?'` char literal and missing `defguardp` keyword [Kevin Bloch][]
1314
- fix(diff) fix unified diff hunk header regex to allow unpaired numbers [Chris Wilson][]
1415
- enh(php) support single line and hash comments in attributes, constructor and functions [Antoine Musso][]
1516
- fix(rust) ensure brackets are balanced within attributes [ewwwin][]
@@ -19,6 +20,7 @@ CONTRIBUTORS
1920
[Josh Marchand]: https://github.com/yHSJ
2021
[Max Liashuk]: https://github.com/probil
2122
[Max Reznik]: https://github.com/reznikmm
23+
[Kevin Bloch]: https://github.com/codingthat
2224
[Chris Wilson]: https://github.com/sushicw
2325
[Antoine Musso]: https://github.com/hashar
2426
[Chester Moses]: https://github.com/Chester-Moses-HCL

src/languages/elixir.js

+7
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export default function(hljs) {
2020
"cond",
2121
"defstruct",
2222
"defguard",
23+
"defguardp",
2324
"do",
2425
"else",
2526
"end",
@@ -228,7 +229,13 @@ export default function(hljs) {
228229
beginKeywords: 'defimpl defmodule defprotocol defrecord',
229230
end: /\bdo\b|$|;/
230231
});
232+
const CHAR_LITERAL = {
233+
scope: 'string',
234+
match: /\?'/,
235+
relevance: 0
236+
};
231237
const ELIXIR_DEFAULT_CONTAINS = [
238+
CHAR_LITERAL,
232239
STRING,
233240
REGEX_SIGIL,
234241
UPCASE_SIGIL,

test/detect/elixir/default.txt

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ guy = Person.new first_name: "Guy"
1010
guy.name
1111

1212
defmodule ListServer do
13+
defguardp apostrophe?(c) when c == ?'
1314
@moduledoc """
1415
This module provides an easy to use ListServer, useful for keeping
1516
lists of things.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<span class="hljs-keyword">defguardp</span> apostrophe?(c) <span class="hljs-keyword">when</span> c == <span class="hljs-string">?&#x27;</span>
2+
<span class="hljs-keyword">defguardp</span> upper?(c) <span class="hljs-keyword">when</span> (c &gt;= ?A <span class="hljs-keyword">and</span> c &lt;= ?Z)

test/markup/elixir/char-literal.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
defguardp apostrophe?(c) when c == ?'
2+
defguardp upper?(c) when (c >= ?A and c <= ?Z)

0 commit comments

Comments
 (0)