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 diff --git a/src/languages/python.js b/src/languages/python.js index 46ed88a6f0..cb152d1b6c 100644 --- a/src/languages/python.js +++ b/src/languages/python.js @@ -384,7 +384,7 @@ export default function(hljs) { hljs.HASH_COMMENT_MODE, { match: [ - /def/, /\s+/, + /\bdef/, /\s+/, IDENT_RE, ], scope: { @@ -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 ], } 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