Show More
@@ -11,6 +11,9 b' import re' | |||||
11 | # System library imports. |
|
11 | # System library imports. | |
12 | from IPython.external.qt import QtGui |
|
12 | from IPython.external.qt import QtGui | |
13 |
|
13 | |||
|
14 | # IPython imports | |||
|
15 | from IPython.utils import py3compat | |||
|
16 | ||||
14 | #----------------------------------------------------------------------------- |
|
17 | #----------------------------------------------------------------------------- | |
15 | # Constants |
|
18 | # Constants | |
16 | #----------------------------------------------------------------------------- |
|
19 | #----------------------------------------------------------------------------- | |
@@ -92,7 +95,6 b' class HtmlExporter(object):' | |||||
92 | box.setInformativeText(info) |
|
95 | box.setInformativeText(info) | |
93 | box.addButton(ib, QtGui.QMessageBox.NoRole) |
|
96 | box.addButton(ib, QtGui.QMessageBox.NoRole) | |
94 | box.addButton(eb, QtGui.QMessageBox.YesRole) |
|
97 | box.addButton(eb, QtGui.QMessageBox.YesRole) | |
95 | box.setDefaultButton(ib) |
|
|||
96 | layout.setSpacing(0) |
|
98 | layout.setSpacing(0) | |
97 | layout.addWidget(box) |
|
99 | layout.addWidget(box) | |
98 | layout.addWidget(checkbox) |
|
100 | layout.addWidget(checkbox) | |
@@ -141,6 +143,8 b' def export_html(html, filename, image_tag = None, inline = True):' | |||||
141 | """ |
|
143 | """ | |
142 | if image_tag is None: |
|
144 | if image_tag is None: | |
143 | image_tag = default_image_tag |
|
145 | image_tag = default_image_tag | |
|
146 | else: | |||
|
147 | image_tag = ensure_utf8(image_tag) | |||
144 |
|
148 | |||
145 | if inline: |
|
149 | if inline: | |
146 | path = None |
|
150 | path = None | |
@@ -172,6 +176,8 b' def export_xhtml(html, filename, image_tag=None):' | |||||
172 | """ |
|
176 | """ | |
173 | if image_tag is None: |
|
177 | if image_tag is None: | |
174 | image_tag = default_image_tag |
|
178 | image_tag = default_image_tag | |
|
179 | else: | |||
|
180 | image_tag = ensure_utf8(image_tag) | |||
175 |
|
181 | |||
176 | with open(filename, 'w') as f: |
|
182 | with open(filename, 'w') as f: | |
177 | # Hack to make xhtml header -- note that we are not doing any check for |
|
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 | return '' |
|
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 | def fix_html(html): |
|
233 | def fix_html(html): | |
214 | """ Transforms a Qt-generated HTML string into a standards-compliant one. |
|
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