Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct handling of ansi colour codes when nbconverting to latex #4807

Merged
merged 3 commits into from Jan 29, 2014
Merged

Correct handling of ansi colour codes when nbconverting to latex #4807

merged 3 commits into from Jan 29, 2014

Conversation

richardeverson
Copy link
Contributor

nbconvert leaves non-printing characters such as ^[[m in latex after nbconversion of notebooks with ansi colour codes (e.g., from ls). Latex can't cope with these even with unicode packages correctly installed, see PR 4806. This PR corrects this and interprets blinking ansi codes as bold. It adds tests for the ansi reset code "\x1b[m" and bold characters to the unit tests.

Correctly deals with "reset" codes and short codes.  Interprets blinking
style as bold.
@richardeverson
Copy link
Contributor Author

This fails Travis CI build in the terminal group. However, it passes all tests with iptest locally.

$ iptest terminal

IPython test group: terminal

........................

Ran 24 tests in 6.285s

OK


Test suite completed for system with the following information:
IPython version: 2.0.0-dev
IPython commit : 0c6c304 (installation)
IPython package: ~/anaconda/envs/test/lib/python2.7/site-packages/IPython
Python version : 2.7.5 |Anaconda 1.8.0 (x86_64)| (default, Oct 24 2013, 07:02:20) [GCC 4.0.1 (Apple Inc. build 5493)]
sys.executable : ~/anaconda/envs/test/bin/python
Platform : Darwin-13.0.0-x86_64-i386-64bit

Tools and libraries available at test time:
curses cython jinja2 matplotlib numpy pexpect pygments qt requests sphinx sqlite3 tornado zmq

Tools and libraries NOT available at test time:
azure casperjs oct2py pymongo rpy2

Status: OK (1 test groups). Took 11.937s.

The PR is confined to IPython/nbconvert/filters/ansi.py and IPython/nbconvert/filters/tests/test_ansi.py so it is hard to see how this could affect the terminal group.

What is the procedure for re-running the Travis CI build?

@takluyver
Copy link
Member

I prodded Travis to re-run (one of us has to do it), and it's passed now.

@richardeverson
Copy link
Contributor Author

Brilliant, thanks. I hope the PR can be considered now.

'hello' : 'hello'}
'hello' : 'hello',
u'hello\x1b[34mthere\x1b[mworld' : u'hello{\\color{blue}there}world',
u'hello\x1b[mthere': u'hellothere'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a test for u'hello\x1b[01;34mthere', which I think will not be correctly handled just yet.

New test case from MinRK.
minrk added a commit that referenced this pull request Jan 29, 2014
Correct handling of ansi colour codes when nbconverting to latex
@minrk minrk merged commit 0e8b6d2 into ipython:master Jan 29, 2014
@richardeverson richardeverson deleted the ansilatex branch January 29, 2014 21:27
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
Correct handling of ansi colour codes when nbconverting to latex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants