Skip to content
This repository

qtconsole export xhtml/utf8 #1099

Closed
wants to merge 1 commit into from

1 participant

Matthias Bussonnier
Matthias Bussonnier
Collaborator

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...

Matthias Bussonnier 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
Matthias Bussonnier
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Dec 04, 2011
Matthias Bussonnier 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
This page is out of date. Refresh to see the latest.
2  IPython/frontend/qt/console/rich_ipython_widget.py
@@ -198,7 +198,7 @@ def _get_image_tag(self, match, path = None, format = "png"):
198 198
199 199 elif format == "svg":
200 200 try:
201   - svg = str(self._name_to_svg_map[match.group("name")])
  201 + svg = self._name_to_svg_map[match.group("name")]
202 202 except KeyError:
203 203 return "<b>Couldn't find image %s</b>" % match.group("name")
204 204
6 IPython/frontend/qt/rich_text.py
@@ -7,6 +7,7 @@
7 7 # Standard library imports.
8 8 import os
9 9 import re
  10 +import codecs
10 11
11 12 # System library imports.
12 13 from IPython.external.qt import QtGui
@@ -182,8 +183,9 @@ def export_xhtml(html, filename, image_tag=None):
182 183 html[offset+6:])
183 184
184 185 html = fix_html(html)
185   - f.write(IMG_RE.sub(lambda x: image_tag(x, path = None, format = "svg"),
186   - html))
  186 + sub=IMG_RE.sub(lambda x: image_tag(x, path = None, format = "svg"), html)
  187 + f.write( codecs.BOM_UTF8 )
  188 + f.write( sub.encode("utf-8") )
187 189
188 190
189 191 def default_image_tag(match, path = None, format = "png"):

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.