##// END OF EJS Templates
single HTML option, inline only asked if images present
MinRK -
Show More
@@ -544,9 +544,8 b' class ConsoleWidget(Configurable, QtGui.QWidget):'
544 544 dialog = QtGui.QFileDialog(parent, 'Save Console as...')
545 545 dialog.setAcceptMode(QtGui.QFileDialog.AcceptSave)
546 546 filters = [
547 'HTML with inline PNGs (*.html *.htm)',
548 'HTML with external PNGs (*.html *.htm)',
549 'XHTML with inline SVGs (*.xhtml *.xml)'
547 'HTML with PNG figures (*.html *.htm)',
548 'XHTML with inline SVG figures (*.xhtml *.xml)'
550 549 ]
551 550 dialog.setNameFilters(filters)
552 551 if self._filename:
@@ -562,7 +561,7 b' class ConsoleWidget(Configurable, QtGui.QWidget):'
562 561 if choice.startswith('XHTML'):
563 562 exporter = self.export_xhtml
564 563 else:
565 exporter = lambda filename: self.export_html(filename, 'inline' in choice)
564 exporter = self.export_html
566 565
567 566 try:
568 567 return exporter(filename)
@@ -573,7 +572,7 b' class ConsoleWidget(Configurable, QtGui.QWidget):'
573 572 QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
574 573 return None
575 574
576 def export_html(self, filename, inline=False):
575 def export_html(self, filename):
577 576 """ Export the contents of the ConsoleWidget as HTML.
578 577
579 578 Parameters:
@@ -585,7 +584,21 b' class ConsoleWidget(Configurable, QtGui.QWidget):'
585 584 include them as links to external PNG files, mimicking
586 585 web browsers' "Web Page, Complete" behavior.
587 586 """
588 if(inline):
587 # N.B. this is overly restrictive, but Qt's output is
588 # predictable...
589 img_re = re.compile(r'<img src="(?P<name>[\d]+)" />')
590 html = self.fix_html_encoding(
591 str(self._control.toHtml().toUtf8()))
592 if img_re.search(html):
593 # there are images
594 title = self.window().windowTitle()
595 reply = QtGui.QMessageBox.question(self, title, "Images found."+
596 "\nWould you like inline PNGs (single large html file) or "+
597 "external image files?", "inline", "external")
598 inline = (reply == 0)
599 else:
600 inline = True
601 if inline:
589 602 path = None
590 603 else:
591 604 root,ext = os.path.splitext(filename)
@@ -595,11 +608,6 b' class ConsoleWidget(Configurable, QtGui.QWidget):'
595 608
596 609 f = open(filename, 'w')
597 610 try:
598 # N.B. this is overly restrictive, but Qt's output is
599 # predictable...
600 img_re = re.compile(r'<img src="(?P<name>[\d]+)" />')
601 html = self.fix_html_encoding(
602 str(self._control.toHtml().toUtf8()))
603 611 f.write(img_re.sub(
604 612 lambda x: self.image_tag(x, path = path, format = "png"),
605 613 html))
General Comments 0
You need to be logged in to leave comments. Login now