return default colors, if pygments cannot find the name
@@ -10,6 +10,7 @@ from qtpy import QtCore, QtGui, QtWidgets
from ipython_genutils.path import ensure_dir_exists
from traitlets import Bool
+from pygments.util import ClassNotFound
from qtconsole.svg import save_svg, svg_to_clipboard, svg_to_image
from .jupyter_widget import JupyterWidget
from .styles import get_colors
@@ -213,7 +214,13 @@ class RichJupyterWidget(RichIPythonWidget):
return False
def _get_colors(self, color):
+ """Get colors from the current syntax style if loadable"""
+ try:
return get_colors(self.syntax_style)[color]
+ except ClassNotFound:
+ # the syntax_style has been sideloaded (e.g. by spyder)
+ # in this case the overloading class should override this method
+ return get_colors('default')[color]
def _append_latex(self, latex, before_prompt=False, metadata=None):
""" Append latex data to the widget."""
