Thanks - that should have been obvious, but it wasn't at the time.  This 
works, loading two external stylesheets:

treedown = 
"/Users/jonathan/git/greek-new-testament/syntax-trees/nestle1904-lowfat/xml/treedown.css"
boxwoodcss = 
"/Users/jonathan/git/greek-new-testament/syntax-trees/nestle1904-lowfat/xml/boxwood.css"

def boxwood(xml):
    formatter = HtmlFormatter()
    display(HTML('<style type="text/css">{}{}</style>{}'.format(
        open(treedown).readlines(),
        open(boxwoodcss).readlines(),
        xml)))

Jonathan

On Thursday, November 30, 2017 at 6:12:24 AM UTC-5, takowl wrote:
>
> Like your previous example, I think - assemble an HTML fragment including 
> a <style> tag, and then display that.
>
> On 29 November 2017 at 23:30, Jonathan Robie <[email protected] 
> <javascript:>> wrote:
>
>> I am writing some notebooks for processing Greek syntax trees using XPath 
>> / XQuery:
>>
>>
>> https://github.com/biblicalhumanities/greek-new-testament/blob/master/labnotes/basex-tutorial.ipynb
>>
>> https://github.com/biblicalhumanities/greek-new-testament/blob/master/labnotes/lxml-tutorial.ipynb
>>
>> I can pretty print the XML like this:
>>
>> from pygments import highlightfrom pygments.lexers import XmlLexerfrom 
>> pygments.formatters import HtmlFormatterimport 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
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Project Jupyter" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jupyter/43b5073b-09a2-449c-b1e4-6c95ab3871ac%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/jupyter/43b5073b-09a2-449c-b1e4-6c95ab3871ac%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jupyter/6ae25f6d-b460-425e-abd4-91c46bff448f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to