##// END OF EJS Templates
Backport PR #4849: Various unicode fixes (mostly on Windows)...
Backport PR #4849: Various unicode fixes (mostly on Windows) There were warnings on startup of IPython, and the qtconsole and notebook could not be started at all if the user's home directory is unicode. Changes: - add `prefer_stream=True` flag to utils.encoding.getdefaultencoding, since the right answer is different for stream output and other things. - always encode args to Popen on Windows Python 2 - never add unicode to sys.path on Python 2 These should be backported for 1.2, and it would be great if some unicode-locale Windows users (@jstenar) could double check the sanity of the changes.

File last commit:

r11086:c137395d
r14916:7cbbbbc4
Show More
lexers.py
46 lines | 1.7 KiB | text/x-python | PythonLexer
David Warde-Farley
Introduce standard structure from coding guidelines in converters/.
r8789 """A custom pygments lexer for IPython code cells.
Informs The pygments highlighting library of the quirks of IPython's superset
of Python -- magic commands, !shell commands, etc.
"""
#-----------------------------------------------------------------------------
Jonathan Frederic
Comment & Refactor, utils and nbconvert main.
r10673 # Copyright (c) 2013, the IPython Development Team.
David Warde-Farley
Introduce standard structure from coding guidelines in converters/.
r8789 #
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
MinRK
add IPython lexer for pygments
r7912 #-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
David Warde-Farley
Introduce standard structure from coding guidelines in converters/.
r8789 # Third-party imports
MinRK
add IPython lexer for pygments
r7912 from pygments.lexers import PythonLexer, BashLexer
from pygments.lexer import bygroups, using
David Warde-Farley
Unused imports.
r8748 from pygments.token import Keyword, Operator, Text
MinRK
add IPython lexer for pygments
r7912 #-----------------------------------------------------------------------------
David Warde-Farley
More descriptive comment headers.
r8808 # Class declarations
MinRK
add IPython lexer for pygments
r7912 #-----------------------------------------------------------------------------
class IPythonLexer(PythonLexer):
Jonathan Frederic
Comment & Refactor, utils and nbconvert main.
r10673 """
Pygments Lexer for use with IPython code. Inherits from
PythonLexer and adds information about IPython specific
keywords (i.e. magic commands, shell commands, etc.)
"""
#Basic properties
MinRK
add IPython lexer for pygments
r7912 name = 'IPython'
aliases = ['ip', 'ipython']
filenames = ['*.ipy']
Jonathan Frederic
Comment & Refactor, utils and nbconvert main.
r10673
#Highlighting information
MinRK
add IPython lexer for pygments
r7912 tokens = PythonLexer.tokens.copy()
tokens['root'] = [
David Warde-Farley
PEP8-ify rest of the repository.
r8749 (r'(\%+)(\w+)\s+(\.*)(\n)', bygroups(Operator, Keyword,
using(BashLexer), Text)),
MinRK
add IPython lexer for pygments
r7912 (r'(\%+)(\w+)\b', bygroups(Operator, Keyword)),
(r'^(!)(.+)(\n)', bygroups(Operator, using(BashLexer), Text)),
Jonathan Frederic
Comment & Refactor, utils and nbconvert main.
r10673 ] + tokens['root']