Skip to content

Commit 04d43eb

Browse files
committed
fix(ex) #4238 and add test
1 parent 85b2042 commit 04d43eb

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
@@ -8,12 +8,14 @@ Core Grammars:
88

99
- enh(csp) add missing directives / keywords from MDN (7 more) [Max Liashuk][]
1010
- enh(ada) add new `parallel` keyword, allow `[]` for Ada 2022 [Max Reznik][]
11+
- fix(ex) adds support for `?'` char literal and missing `defguardp` keyword [Kevin Bloch][]
1112

1213
CONTRIBUTORS
1314

1415
[Josh Marchand]: https://github.com/yHSJ
1516
[Max Liashuk]: https://github.com/probil
1617
[Max Reznik]: https://github.com/reznikmm
18+
[Kevin Bloch]: https://github.com/codingthat
1719

1820
## Version 11.11.1
1921

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+
className: 'string',
234+
begin: /\?'/,
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)