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

pycon lexer outputs all grey text #65

Closed
moorepants opened this issue Feb 13, 2015 · 11 comments
Closed

pycon lexer outputs all grey text #65

moorepants opened this issue Feb 13, 2015 · 11 comments

Comments

@moorepants
Copy link

Hi,

I'm using minted to highlight a Python console session but it outputs all grey text instead of highlighting it properly. The PR showing my code is here:

chrisdembia/python-yeadon-paper#50

The example code is:

>>> import yeadon
>>> pi = 3.14159
>>> # Load a prepared measurements file.
>>> h = yeadon.Human('male1.txt')
>>> # Create a 3D rendering of the model.
>>> h.draw()
>>> # Print the moment inertia about the global Z axis.
>>> print('Arms down: {:.2f} kg-m^2'.format(h.inertia[2, 2])
Arms down: 0.55 kg-m^2
>>> # Set the configuration of the shoulder angle.
>>> h.set_CFG('CA1adduction', -0.5 * pi)
>>> h.set_CFG('CB1abduction', 0.5 * pi)
>>> # Print the updated moment inertia about the global Z axis.
>>> print('Arms out: {:.2f} kg-m^2'.format(h.inertia[2, 2]))
Arms out: 1.58 kg-m^2

It works on the Pygments website:

http://pygments.org/demo/1302679/

But looks like this on my machine build and on the sharelatex CI build:

selection_052

I have pygments 1.6:

moorepants@moorepants-2170p:python-yeadon-paper(issue-15)$ pygmentize -V
Pygments version 1.6, (c) 2006-2013 by Georg Brandl.

Am I doing something wrong?

@moorepants
Copy link
Author

Also, I'm on texlive 2013.20140215-1 on Ubuntu 14.04. I'm not sure how to find the minted version number.

@gpoore
Copy link
Owner

gpoore commented Feb 13, 2015

It works fine for me with minted 2.0 and Pygments 1.6. The minted version shouldn't matter for this, though.

Can you give me a complete example document that causes the problem? There might be a package conflict.

@chrisdembia
Copy link

I have the issue on Ubuntu 14.04 as well. @moorepants I found my minted version by reading /usr/share/texlive/texmf-dist/tex/latex/minted/minted.sty, which said I have v1.7.

@moorepants
Copy link
Author

Yes @gpoore, see the document here: chrisdembia/python-yeadon-paper#50

@moorepants
Copy link
Author

Thanks @chrisdembia I have 1.7 installed also.

@gpoore
Copy link
Owner

gpoore commented Feb 13, 2015

This is due to a particular interaction between your document and Pygments. You are using minted as at https://github.com/chrisdembia/python-yeadon-paper/blob/issue-15/main.tex#L516-537. The code is indented, and then you use gobble to remove the extra indentation. However, apparently Pygments applies filters (such as gobble) after lexing; see this. It appears that the pycon lexing assumes no indentation to properly identify input/output. Ultimately, it's a clash between lexing and the gobble filter.

If you try your code at the Pygments site, but indent it, you get the same grey results.

In terms of working around this, you have a few options. You could just not indent the code. Or, you could upgrade to minted 2.0, which adds an autogobble options. This strips all common leading whitespace, using Python, before sending the code to Pygments. Since Pygments doesn't do the gobbling, the whole lex-before-filter thing is bypassed. You can use autogobble on a per-environment basis. But the simplest thing would be \setminted[pycon]{autogobble}. Of course, you will want to remove all the gobble settings.

@moorepants
Copy link
Author

@gpoore Awesome, thanks for the debug and the great package!

We will just unindent for this situation. I'll wait on minted 2.0 to get into texlive instead of installing it manually.

Thanks!

@klmr
Copy link
Contributor

klmr commented Feb 13, 2015

minted 2.0 is already on TeX Live. You should be able to update it via tlmgr immediately.

@moorepants
Copy link
Author

@klmr thanks for the tip. I assume tlmgr is a texlive specific package manager? I'll have to read about it first before I use it. Does it only install to /usr/local and leave the apt based system installs inplace?

@moorepants
Copy link
Author

We use the ShareLaTeX CI Github integration and they seem to have minted < 2.0, so I'll probably just go with the work around above.

@klmr
Copy link
Contributor

klmr commented Feb 13, 2015

tlmgr is the TeX Live package manager. I don’t actually have too much experience with it, since the Mac distribution of TeX Live ships with a GUI (TeX Live Utility) which wraps the package manager. As such, I don’t know how it interferes with the apt installation, sorry.

@gpoore gpoore closed this as completed Jun 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants