Skip to content

Commit 2d29294

Browse files
committed
Add better support for Python functions and props
1 parent 5697ae5 commit 2d29294

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/languages/python.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,39 @@ export default function(hljs) {
383383
relevance: 0
384384
},
385385
{ match: /\bor\b/, scope: "keyword" },
386+
// Method calls with parentheses
387+
{
388+
match: [
389+
/\./,
390+
IDENT_RE,
391+
/(?=\s*\()/
392+
],
393+
scope: {
394+
2: "title.function.method"
395+
}
396+
},
397+
// Chained method calls
398+
{
399+
match: [
400+
/\./,
401+
IDENT_RE,
402+
/(?=\s*\.\s*\w)/
403+
],
404+
scope: {
405+
2: "title.function.method"
406+
}
407+
},
408+
{
409+
match: [
410+
/(?<!(?:import|from)\s+[\w.]*)/, // Negative lookbehind for import context
411+
/\./, // Literal dot
412+
IDENT_RE, // Property name
413+
/(?!\s*[\(\[])/ // Not followed by ( or [
414+
],
415+
scope: {
416+
3: "property"
417+
}
418+
},
386419
STRING,
387420
COMMENT_TYPE,
388421
hljs.HASH_COMMENT_MODE,

0 commit comments

Comments
 (0)