From 56981f5ba67361a74d6a9bcc014ab96339e26a0b Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Sun, 31 Oct 2021 21:34:21 -0400 Subject: [PATCH 1/2] fix(python) `def`, `class keywords detected mid-identifier --- src/languages/python.js | 6 +++--- test/markup/python/false_positives.expect.txt | 5 +++++ test/markup/python/false_positives.txt | 5 +++++ 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 test/markup/python/false_positives.expect.txt create mode 100644 test/markup/python/false_positives.txt diff --git a/src/languages/python.js b/src/languages/python.js index ce603a86d4..58b9889b76 100644 --- a/src/languages/python.js +++ b/src/languages/python.js @@ -378,7 +378,7 @@ export default function(hljs) { hljs.HASH_COMMENT_MODE, { match: [ - /def/, /\s+/, + /\bdef/, /\s+/, IDENT_RE, ], scope: { @@ -391,14 +391,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 ], } diff --git a/test/markup/python/false_positives.expect.txt b/test/markup/python/false_positives.expect.txt new file mode 100644 index 0000000000..cce88e6df8 --- /dev/null +++ b/test/markup/python/false_positives.expect.txt @@ -0,0 +1,5 @@ +foo = _undef +bar + +booger = _unclass +burger diff --git a/test/markup/python/false_positives.txt b/test/markup/python/false_positives.txt new file mode 100644 index 0000000000..cce88e6df8 --- /dev/null +++ b/test/markup/python/false_positives.txt @@ -0,0 +1,5 @@ +foo = _undef +bar + +booger = _unclass +burger From 1b73907b2dd374557f796e7f3428fa086b571b27 Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Tue, 16 Nov 2021 12:13:03 -0500 Subject: [PATCH 2/2] changelog --- CHANGES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 59324b44b6..5ca677923e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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][] @@ -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