Skip to content

Commit

Permalink
Python: Fixed decorators (#2018)
Browse files Browse the repository at this point in the history
This adds a missing multiline flag to support more than one decorator.
  • Loading branch information
RunDevelopment committed Aug 29, 2019
1 parent 9f72258 commit 5b8a16d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
4 changes: 2 additions & 2 deletions components/prism-python.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Prism.languages.python = {
lookbehind: true
},
'decorator': {
pattern: /(^\s*)@\w+(?:\.\w+)*/i,
pattern: /(^\s*)@\w+(?:\.\w+)*/im,
lookbehind: true,
alias: ['annotation', 'punctuation'],
inside: {
Expand All @@ -61,4 +61,4 @@ Prism.languages.python = {

Prism.languages.python['string-interpolation'].inside['interpolation'].inside.rest = Prism.languages.python;

Prism.languages.py = Prism.languages.python;
Prism.languages.py = Prism.languages.python;
2 changes: 1 addition & 1 deletion components/prism-python.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 32 additions & 3 deletions tests/languages/python/decorator_feature.test
Original file line number Diff line number Diff line change
@@ -1,19 +1,48 @@
@some.decorator(foobar)
def foo(bar):
pass
pass

@decorator
def foo(bar):
pass

@decorator
def foo(bar):
pass

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

[
["decorator", [
"@some",
["punctuation", "."],
"decorator"]
],
"decorator"
]],
["punctuation", "("],
"foobar",
["punctuation", ")"],
["keyword", "def"],
["function", "foo"],
["punctuation", "("],
"bar",
["punctuation", ")"],
["punctuation", ":"],
["keyword", "pass"],

["decorator", [
"@decorator"
]],
["keyword", "def"],
["function", "foo"],
["punctuation", "("],
"bar",
["punctuation", ")"],
["punctuation", ":"],
["keyword", "pass"],

["decorator", [
"@decorator"
]],
["keyword", "def"],
["function", "foo"],
["punctuation", "("],
Expand Down

0 comments on commit 5b8a16d

Please sign in to comment.