Show More
@@ -0,0 +1,22 b'' | |||||
|
1 | #----------------------------------------------------------------------------- | |||
|
2 | # Imports | |||
|
3 | #----------------------------------------------------------------------------- | |||
|
4 | ||||
|
5 | from pygments.lexers import PythonLexer, BashLexer | |||
|
6 | from pygments.lexer import bygroups, using | |||
|
7 | from pygments.token import Keyword, Operator, Name, Text | |||
|
8 | ||||
|
9 | #----------------------------------------------------------------------------- | |||
|
10 | # Classes | |||
|
11 | #----------------------------------------------------------------------------- | |||
|
12 | ||||
|
13 | class IPythonLexer(PythonLexer): | |||
|
14 | name = 'IPython' | |||
|
15 | aliases = ['ip', 'ipython'] | |||
|
16 | filenames = ['*.ipy'] | |||
|
17 | tokens = PythonLexer.tokens.copy() | |||
|
18 | tokens['root'] = [ | |||
|
19 | (r'(\%+)(\w+)\s+(\.*)(\n)', bygroups(Operator, Keyword, using(BashLexer), Text)), | |||
|
20 | (r'(\%+)(\w+)\b', bygroups(Operator, Keyword)), | |||
|
21 | (r'^(!)(.+)(\n)', bygroups(Operator, using(BashLexer), Text)), | |||
|
22 | ] + tokens['root'] |
General Comments 0
You need to be logged in to leave comments.
Login now