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

ipy.highlighting_style can be a string #7

Closed
njsmith opened this issue Jan 2, 2018 · 2 comments
Closed

ipy.highlighting_style can be a string #7

njsmith opened this issue Jan 2, 2018 · 2 comments

Comments

@njsmith
Copy link

njsmith commented Jan 2, 2018

  • PrettyPrinter version: 0.8.0

According to https://ipython.readthedocs.io/en/stable/config/details.html#terminal-colors:

TerminalInteractiveShell.highlighting_style determines prompt colours and syntax highlighting. It takes the name (as a string) or class (as a subclass of pygments.style.Style) of a Pygments style, or the special value 'legacy' to pick a style in accordance with InteractiveShell.colors.

(emphasis added). But if I set highlighting_style = "default" in my IPython startup file, and enable prettyprinter integration, then I get a traceback ending in:

~/.user-python3.5-64bit/local/lib/python3.5/site-packages/prettyprinter/color.py in colored_render_to_stream(stream, sdocs, style, newline, separator)
    213                     except KeyError:
    214                         pygments_token = _SYNTAX_TOKEN_TO_PYGMENTS_TOKEN[sdoc.value]
--> 215                         tokenattrs = style.style_for_token(pygments_token)
    216                         color = styleattrs_to_colorful(tokenattrs)
    217                         color_cache[sdoc.value] = color

AttributeError: 'str' object has no attribute 'style_for_token'

I think there's some missing if instance(style, str): style = pygments.styles.get_style_by_name(style)

@tommikaikkonen
Copy link
Owner

Thanks! Should be fixed in 0.8.1 that I pushed to PyPi.

11a4e1a

@njsmith
Copy link
Author

njsmith commented Jan 2, 2018

Yep, works for me, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants