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

Backwards compatible HTML generation #43

Closed
shoyer opened this issue Nov 13, 2017 · 4 comments
Closed

Backwards compatible HTML generation #43

shoyer opened this issue Nov 13, 2017 · 4 comments

Comments

@shoyer
Copy link

shoyer commented Nov 13, 2017

As discussed over in jupyterlab/jupyterlab#3200, for use in older notebook interfaces, it would be valuable if vdom exposed an easy way of generating HTML.

@fperez
Copy link

fperez commented Dec 11, 2017

👍 ! This reminds me of an old tool that I used back in 2002, called HTMLgen (I think it doesn't exist anymore, the new htmlgen package is something else). It allowed for really easy creation of HTML documents programmatically, this is some of my old code from my dissertation, creating pages with auto-generated images from numerical simulations:

import HTMLgen as html

doc = html.SimpleDocument(title=fname)
doc.append(html.Heading(1,fname,align='center'))

# now make a table with the images
tab = html.Table('Slices along %s direction' % dir,
                 column1_align='center',cell_align='center')
tab.body = []
col = 1; l1 = []; l2 = []
for img in images:
    l1.append(html.Image(img[1]))
    l2.append(img[0])
    if col%3:
        col += 1
    else:
        #print 'finished row' # dbg
        tab.body.extend([l1,l2])
        col = 1; l1 = []; l2 = []
doc.append(tab)
doc.write(os.path.join(html_dir,'index.html'))

I haven't needed to do something quite like this lately, but last I'd looked, there really wasn't anything as convenient as this. Looking at the vdom examples feels very natural and reminds me of this code. It would be great to have not only the interactive in-notebook capabilities, but also, where possible, plain html output. I suspect this would be useful not only for classic nb but also possibly in nbviewer/nbconvert/sphinx contexts.

@fperez
Copy link

fperez commented Dec 11, 2017

ps - interesting bit of archeology, HTMLgen is still online. Since they highlight that it reuires python 1.5 or later, I'm going to bet it may not have seen much maintenance lately :)

@yuvipanda
Copy link
Contributor

I might take a shot at this :)

@rgbkrk what do you think about taking a dependency on lxml2 for this? It has wheels for all major platforms so should be ok? If not I'll try make a pure non-dependent version.

@rgbkrk
Copy link
Member

rgbkrk commented Apr 19, 2018

That seems sensible. Amusingly I've gone the other direction as well using xml, converting HTML to VDOM nodes with xml.dom's minidom.

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

4 participants