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

Set python3 option for console lexer #156

Open
AndrewSwann opened this issue Sep 14, 2019 · 2 comments
Open

Set python3 option for console lexer #156

AndrewSwann opened this issue Sep 14, 2019 · 2 comments

Comments

@AndrewSwann
Copy link

AndrewSwann commented Sep 14, 2019

For python 3 code I can specify the lexer for verbatim environments as py3, but for console output I wish to use the pycon lexer with its python3=True option. Currently I see no mechanism to pass this option in pythontex to pygmatize, whereas minted has an option for this.

Here is a sample document where the highlighting of the @ operator in the console output is wrong.

Screenshot 2019-09-14 at 16 32 03

\documentclass{article}

\usepackage{pythontex}
\setpythontexpyglexer[py]{py3}

\begin{document}

\begin{pyconsole}
print(sys.version)
import numpy as np
print(np.array([[1,0],[0,1]]) @ np.array([[0,1]])
\end{pyconsole}

\begin{pyverbatim}
print(sys.version)
import numpy as np
print(np.array([[1,0],[0,1]]) @ np.array([[0,1]])
\end{pyverbatim}

\end{document}

@gpoore
Copy link
Owner

gpoore commented Sep 20, 2019

At this point, everything really should default to Python 3 compatibility. In the last commit, I've set pycon to use python3=True always and also changed the default Python lexer to python3. Adding support for setting arbitrary lexer options is more complicated given the current design, so I will look into that later.

@AndrewSwann
Copy link
Author

AndrewSwann commented Sep 25, 2019 via email

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

2 participants