I am writing some notebooks for processing Greek syntax trees using XPath / XQuery:
from pygments import highlight
from pygments.lexers import XmlLexer
from pygments.formatters import HtmlFormatter
import IPython
def xml_display(xml):
formatter = HtmlFormatter()
display(
IPython.display.HTML('<style type="text/css">{}</style>{}'.format (
formatter.get_style_defs('.highlight'),
highlight(xml, XmlLexer(), formatter))))
def xquery_display(query):
xml_display(xquery(query))
But I also want to be able to display results using .css as though they were in a browser. This looks like it should be straightforward, but I'm failing to see the hook that I need.
This works fine, but without a custom .css stylesheet:
def boxwood(xml):
formatter = HtmlFormatter()
display(HTML(xml))
I want to add the .css stylesheet to this. Where do I do that?
Thanks!
Jonathan