Skip to content

Commit

Permalink
fix(python) allow keywords immediately following numbers (#3050)
Browse files Browse the repository at this point in the history
Progress on #2985.
  • Loading branch information
joshgoebel committed Mar 17, 2021
1 parent 338e8c7 commit 87019cb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -12,6 +12,7 @@ New Languages:

Language grammar improvements:

- fix(python) allow keywords immediately following numbers (#2985) [Josh Goebel][]
- fix(xml) char immediately following tag close mis-highlighted (#3044) [Josh Goebel][]
- fix(ruby) fix `defined?()` mis-highlighted as `def` (#3025) [Josh Goebel][]
- fix(c) comments after `#include <str>` blocks (#3041) [Josh Goebel][]
Expand Down
1 change: 1 addition & 0 deletions src/languages/python.js
Expand Up @@ -144,6 +144,7 @@ export default function(hljs) {
];

const KEYWORDS = {
$pattern: /[A-Za-z]\w+|__\w+__/,
keyword: RESERVED_WORDS,
built_in: BUILT_INS,
literal: LITERALS,
Expand Down
3 changes: 3 additions & 0 deletions test/markup/python/keywords.expect.txt
Expand Up @@ -12,3 +12,6 @@ x = Shorty()
<span class="hljs-built_in">print</span>(_)

<span class="hljs-built_in">exec</span>(<span class="hljs-number">123</span>)

<span class="hljs-comment"># note, numbers still aren&#x27;t highlighted fully</span>
<span class="hljs-built_in">print</span>(1<span class="hljs-keyword">if</span> <span class="hljs-number">0</span>==0<span class="hljs-keyword">else</span><span class="hljs-string">&quot;b&quot;</span>)
3 changes: 3 additions & 0 deletions test/markup/python/keywords.txt
Expand Up @@ -12,3 +12,6 @@ for _ in sys.path:
print(_)

exec(123)

# note, numbers still aren't highlighted fully
print(1if 0==0else"b")

0 comments on commit 87019cb

Please sign in to comment.