Skip to content
Permalink
Browse files
Python: Add match and case (soft) keywords (#3142)
  • Loading branch information
hoonweiting committed Oct 7, 2021
1 parent 344d0b2 commit 3f24dc727b3e186b6ad6ef651812a15f8cd8fc04
Showing with 6 additions and 4 deletions.
  1. +1 −1 components/prism-python.js
  2. +1 −1 components/prism-python.min.js
  3. +4 −2 tests/languages/python/keyword_feature.test
@@ -51,7 +51,7 @@ Prism.languages.python = {
'punctuation': /\./
}
},
'keyword': /\b(?:and|as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,
'keyword': /\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,
'builtin': /\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,
'boolean': /\b(?:False|None|True)\b/,
'number': /\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,

Some generated files are not rendered by default. Learn more.

@@ -9,6 +9,7 @@ pass print raise return
try while with yield
nonlocal
and not or
match case _:

----------------------------------------------------

@@ -23,9 +24,10 @@ and not or
["keyword", "pass"], ["keyword", "print"], ["keyword", "raise"], ["keyword", "return"],
["keyword", "try"], ["keyword", "while"], ["keyword", "with"], ["keyword", "yield"],
["keyword", "nonlocal"],
["keyword", "and"], ["keyword", "not"], ["keyword", "or"]
["keyword", "and"], ["keyword", "not"], ["keyword", "or"],
["keyword", "match"], ["keyword", "case"], ["keyword", "_"], ["punctuation", ":"]
]

----------------------------------------------------

Checks for all keywords.
Checks for all keywords.

0 comments on commit 3f24dc7

Please sign in to comment.