diff --git a/CHANGES.md b/CHANGES.md index f85d3ecc51..7f5a0fff36 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -21,6 +21,7 @@ Core Grammars: - fix(csharp) add raw string highlighting for C# 11. [Tara][] - fix(bash) fix # within token being detected as the start of a comment [Felix Uhl][] - fix(python) fix `or` conflicts with string highlighting [Mohamed Ali][] +- enh(python) adds a scope to the `self` variable [Lee Falin][] - enh(delphi) allow digits to be omitted for hex and binary literals [Jonah Jeleniewski][] - enh(delphi) add support for digit separators [Jonah Jeleniewski][] - enh(delphi) add support for character strings with non-decimal numerics [Jonah Jeleniewski][] diff --git a/src/languages/python.js b/src/languages/python.js index e6c46217d5..2604889790 100644 --- a/src/languages/python.js +++ b/src/languages/python.js @@ -373,7 +373,8 @@ export default function(hljs) { NUMBER, { // very common convention - begin: /\bself\b/ + scope: 'variable.language', + match: /\bself\b/ }, { // eat "if" prior to string so that it won't accidentally be diff --git a/test/markup/python/class_self.expect.txt b/test/markup/python/class_self.expect.txt new file mode 100644 index 0000000000..db39ede4a9 --- /dev/null +++ b/test/markup/python/class_self.expect.txt @@ -0,0 +1,6 @@ +class SelfTest: + def __init__(self): + self.text = True + + def method(self): + pass diff --git a/test/markup/python/class_self.txt b/test/markup/python/class_self.txt new file mode 100644 index 0000000000..ef25a10691 --- /dev/null +++ b/test/markup/python/class_self.txt @@ -0,0 +1,6 @@ +class SelfTest: + def __init__(self): + self.text = True + + def method(self): + pass \ No newline at end of file