Show More
@@ -11,6 +11,9 b' import re' | |||
|
11 | 11 | # System library imports. |
|
12 | 12 | from IPython.external.qt import QtGui |
|
13 | 13 | |
|
14 | # IPython imports | |
|
15 | from IPython.utils import py3compat | |
|
16 | ||
|
14 | 17 | #----------------------------------------------------------------------------- |
|
15 | 18 | # Constants |
|
16 | 19 | #----------------------------------------------------------------------------- |
@@ -92,7 +95,6 b' class HtmlExporter(object):' | |||
|
92 | 95 | box.setInformativeText(info) |
|
93 | 96 | box.addButton(ib, QtGui.QMessageBox.NoRole) |
|
94 | 97 | box.addButton(eb, QtGui.QMessageBox.YesRole) |
|
95 | box.setDefaultButton(ib) | |
|
96 | 98 | layout.setSpacing(0) |
|
97 | 99 | layout.addWidget(box) |
|
98 | 100 | layout.addWidget(checkbox) |
@@ -141,6 +143,8 b' def export_html(html, filename, image_tag = None, inline = True):' | |||
|
141 | 143 | """ |
|
142 | 144 | if image_tag is None: |
|
143 | 145 | image_tag = default_image_tag |
|
146 | else: | |
|
147 | image_tag = ensure_utf8(image_tag) | |
|
144 | 148 | |
|
145 | 149 | if inline: |
|
146 | 150 | path = None |
@@ -172,6 +176,8 b' def export_xhtml(html, filename, image_tag=None):' | |||
|
172 | 176 | """ |
|
173 | 177 | if image_tag is None: |
|
174 | 178 | image_tag = default_image_tag |
|
179 | else: | |
|
180 | image_tag = ensure_utf8(image_tag) | |
|
175 | 181 | |
|
176 | 182 | with open(filename, 'w') as f: |
|
177 | 183 | # Hack to make xhtml header -- note that we are not doing any check for |
@@ -210,6 +216,20 b' def default_image_tag(match, path = None, format = "png"):' | |||
|
210 | 216 | return '' |
|
211 | 217 | |
|
212 | 218 | |
|
219 | def ensure_utf8(image_tag): | |
|
220 | """wrapper for ensuring image_tag returns utf8-encoded str on Python 2""" | |
|
221 | if py3compat.PY3: | |
|
222 | # nothing to do on Python 3 | |
|
223 | return image_tag | |
|
224 | ||
|
225 | def utf8_image_tag(*args, **kwargs): | |
|
226 | s = image_tag(*args, **kwargs) | |
|
227 | if isinstance(s, unicode): | |
|
228 | s = s.encode('utf8') | |
|
229 | return s | |
|
230 | return utf8_image_tag | |
|
231 | ||
|
232 | ||
|
213 | 233 | def fix_html(html): |
|
214 | 234 | """ Transforms a Qt-generated HTML string into a standards-compliant one. |
|
215 | 235 |
General Comments 0
You need to be logged in to leave comments.
Login now