Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

qtconsole export xhtml/utf8 #1099

Closed
wants to merge 1 commit into from

1 participant

@Carreau
Owner

using utf-8 to save the qtconsole export as xhtml/svg, to avoid crash on some
kinds of plots, mainly when converting svg to str, or when writing the file

closes #1087

@epatters,
You seem to be the one who wrote that, could you take a look ? I'm not quite familiar with this part (nor with unicode) and I'm wondering if unicode could mess-up somewhere else...

@Carreau Carreau qtconsole export xhtml/utf8
	using utf-8 to save the qtconsole export as xhtml/svg, to avoid crash on some
	kinds of plots, mainly when converting svg to str, or when writing the file

	closes #1087
3b6bc65
@Carreau
Owner

This seem to be a deeper issues as it does not fix it on debian, which crash even before rendering...
see #1087

@Carreau Carreau closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 4, 2011
  1. @Carreau

    qtconsole export xhtml/utf8

    Carreau authored
    	using utf-8 to save the qtconsole export as xhtml/svg, to avoid crash on some
    	kinds of plots, mainly when converting svg to str, or when writing the file
    
    	closes #1087
This page is out of date. Refresh to see the latest.
View
2  IPython/frontend/qt/console/rich_ipython_widget.py
@@ -198,7 +198,7 @@ def _get_image_tag(self, match, path = None, format = "png"):
elif format == "svg":
try:
- svg = str(self._name_to_svg_map[match.group("name")])
+ svg = self._name_to_svg_map[match.group("name")]
except KeyError:
return "<b>Couldn't find image %s</b>" % match.group("name")
View
6 IPython/frontend/qt/rich_text.py
@@ -7,6 +7,7 @@
# Standard library imports.
import os
import re
+import codecs
# System library imports.
from IPython.external.qt import QtGui
@@ -182,8 +183,9 @@ def export_xhtml(html, filename, image_tag=None):
html[offset+6:])
html = fix_html(html)
- f.write(IMG_RE.sub(lambda x: image_tag(x, path = None, format = "svg"),
- html))
+ sub=IMG_RE.sub(lambda x: image_tag(x, path = None, format = "svg"), html)
+ f.write( codecs.BOM_UTF8 )
+ f.write( sub.encode("utf-8") )
def default_image_tag(match, path = None, format = "png"):
Something went wrong with that request. Please try again.