Skip to content

Commit

Permalink
fix(python) def, class keywords detected mid-identifier (#3381)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshgoebel committed Nov 16, 2021
1 parent ef45496 commit 10b322d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Expand Up @@ -2,6 +2,7 @@

Grammars:

- fix(python) def, class keywords detected mid-identifier (#3381) [Josh Goebel][]
- fix(python) Fix recognition of numeric literals followed by keywords without whitespace (#2985) [Richard Gibson][]
- enh(swift) add SE-0290 unavailability condition (#3382) [Bradley Mackey][]
- enh(java) add `sealed` and `non-sealed` keywords (#3386) [Bradley Mackey][]
Expand All @@ -22,6 +23,7 @@ Developer Tools:
[Richard Gibson]: https://github.com/gibson042
[Bradley Mackey]: https://github.com/bradleymackey
[Björn Ebbinghaus]: https://github.com/MrEbbinghaus
[Josh Goebel]: https://github.com/joshgoebel

## Version 11.3.1

Expand Down
6 changes: 3 additions & 3 deletions src/languages/python.js
Expand Up @@ -384,7 +384,7 @@ export default function(hljs) {
hljs.HASH_COMMENT_MODE,
{
match: [
/def/, /\s+/,
/\bdef/, /\s+/,
IDENT_RE,
],
scope: {
Expand All @@ -397,14 +397,14 @@ export default function(hljs) {
variants: [
{
match: [
/class/, /\s+/,
/\bclass/, /\s+/,
IDENT_RE, /\s*/,
/\(\s*/, IDENT_RE,/\s*\)/
],
},
{
match: [
/class/, /\s+/,
/\bclass/, /\s+/,
IDENT_RE
],
}
Expand Down
5 changes: 5 additions & 0 deletions test/markup/python/false_positives.expect.txt
@@ -0,0 +1,5 @@
foo = _undef
bar

booger = _unclass
burger
5 changes: 5 additions & 0 deletions test/markup/python/false_positives.txt
@@ -0,0 +1,5 @@
foo = _undef
bar

booger = _unclass
burger

0 comments on commit 10b322d

Please sign in to comment.