@@ -64,6 +64,7 @@ def make_python_patterns(additional_keywords=[], additional_builtins=[]):
6464 builtinlist = [str (name ) for name in dir (builtins )
6565 if not name .startswith ('_' )] + additional_builtins
6666 builtin = r"([^.'\"\\#]\b|^)" + any ("builtin" , builtinlist ) + r"\b"
67+ builtin_fct = any ("builtin_fct" , [r'_{2}[a-zA-Z_]*_{2}' ])
6768 comment = any ("comment" , [r"#[^\n]*" ])
6869 instance = any ("instance" , [r"\bself\b" , r"\bcls\b" ])
6970 decorator = any ('decorator' , [r'@\w*' , r'.setter' ])
@@ -86,12 +87,11 @@ def make_python_patterns(additional_keywords=[], additional_builtins=[]):
8687 ufstring2 = any ("uf_dqstring" , [uf_dqstring ])
8788 ufstring3 = any ("uf_sq3string" , [uf_sq3string ])
8889 ufstring4 = any ("uf_dq3string" , [uf_dq3string ])
89- return "|" .join ([instance , decorator , kw , builtin , comment , ufstring1 ,
90+ return "|" .join ([instance , decorator , kw , builtin , builtin_fct ,
91+ comment , ufstring1 ,
9092 ufstring2 ,
9193 ufstring3 , ufstring4 , string , number ,
9294 any ("SYNC" , [r"\n" ])])
93-
94-
9595#
9696# Pygments Syntax highlighter
9797#
@@ -165,6 +165,12 @@ def highlight_block(self, text, block):
165165 self .setFormat (start , end - start ,
166166 self .formats ["string" ])
167167 state = self .INSIDE_DQSTRING
168+ elif key == 'builtin_fct' :
169+ # trick to highlight __init__, __add__ and so on with
170+ # builtin color
171+ print (key , value , start , end )
172+ self .setFormat (start , end - start ,
173+ self .formats ["builtin" ])
168174 else :
169175 if '"""' in value and key != 'comment' :
170176 # highlight docstring with a different color
0 commit comments