-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Added HTML export #167
Added HTML export #167
Conversation
Three export options (HTML w/ external PNGs, HTML w/ inline PNGs, and XHTML w/ inline SVGs) are added to the context menu.
Thanks a lot, Mark! I made some minor form comments, but I won't have time to give you more meaningful feedback or testing for a couple of days. But this looks great, and I promise to get back to it and test it. One minor note: you may want to make a feature branch for this, in case it grows and your master picks up other things, so the html-print-specific work stays contained and we can review it in isolation. I think you can edit the source branch for the pull request after the fact. If not don't worry for this one, just keep it in mind for future proposals. |
Mark, this is a really nice go at this. I tested on my Mac with Firefox, Chrome and Safari and all worked fine for all formats. I do think we want all of these choices. The docstrings need to be cleaned up into our standard format. For examples, see a file like IPython/zmq/kernelmanager.py. |
"One minor note: you may want to make a feature branch for this" I've added a feature branch (htmlexport), but can't figure out how to switch the branch for the pull request |
This adds an explicit declaration of the UTF-8 character encoding to the Qt generated HTML dump (since we've just explicitly requested UTF-8 conversion from QString, this declaration should be correct), c.f. http://www.w3.org/International/O-charset This patch fixes incorrect characters (e.g., A-hat for tab) in, e.g., Firefox's default rendering of exported HTML. Applying the same fix to both HTML and XHTML export even though Firefox and WebKit appear to assume UTF-8 for XHTML even without an explicit declaration.
Hi Fernando, |
Merge branch 'master' of http://github.com/markvoorhies/ipython into markvoorhies-master This adds HTML export of the entire buffer of the Qt console, with Closed by aae8597 (pull request). |
…markvoorhies-master This adds HTML export of the entire buffer of the Qt console, with option to save images either as inline PNG, PNGs in a separate folder, or as inline SVG with all original metadata the SVG could have had still intact. Closes ipythongh-167 (pull request).
…markvoorhies-master This adds HTML export of the entire buffer of the Qt console, with option to save images either as inline PNG, PNGs in a separate folder, or as inline SVG with all original metadata the SVG could have had still intact. Closes ipythongh-167 (pull request).
This is my first pass at adding HTML export to ipython. Here's the description that I'm
sending to ipython-dev:
I tried three approaches (available as three context menu options):
Export HTML (external PNGs):
This mimics Firefox's "Save as Web Page, complete" behavior.
Saving "mypath/test.htm" gives an HTML file with links to PNGs in
"mypath/test_files/". The PNGs are named relative to format.name()
to avoid collisions.
Works in Firefox 3.6.10, Konqueror 4.4.2/KHTML, and Konqueror 4.4.2/WebKit
Export HTML (inline PNGs):
Saves a single HTML file with images as inline base64 PNGs
(c.f. http://en.wikipedia.org/wiki/Data_URI_scheme#HTML)
Works in Firefox 3.6.10, Konqueror 4.4.2/KHTML, and Konqueror 4.4.2/WebKit
Export XHTML (inline SVGs):
Saves a single XHTML file with images as inline SVG. The "XML" is generated
by overwriting the Qt-generated document header, so it is not guaranteed to
be valid XML (but Firefox does validate my test case).
Works in Firefox 3.6.10 and Konqueror 4.4.2/WebKit.
Image placement is incorrect for Konqueror 4.4.2/KHTML.
(all tests run on a Dell Latitude D630 w/ Kubuntu Lucid:
mvoorhie@virgil:~$ uname -a
Linux virgil 2.6.32-24-generic #43-Ubuntu SMP Thu Sep 16 14:17:33 UTC 2010 i686 GNU/Linux)
It may be possible to link external SVG images via an or tag,
but I couldn't find a clean/portable way to do this.
Current issues:
get away with it, but we wind up with a few bad character encodings in the
output (e.g., the tabs for multi-line inputs). Would be good for someone who
knows more about unicode to take a look at this...
probably be rewritten to use os.path.
ends will export HTML with the images stripped, unless they implement their own
version of imagetag().
Feel free to take/hack what you like and ditch the rest.
Happy hacking,
--Mark