UI/Previewer.py

branch
Py2 comp.
changeset 3484
645c12de6b0c
parent 3178
f25fc1364c88
parent 3190
a9a94491c4fd
child 3515
1b8381afe38f
equal deleted inserted replaced
3456:96232974dcdb 3484:645c12de6b0c
233 language = "Markdown" 233 language = "Markdown"
234 elif extension in \ 234 elif extension in \
235 Preferences.getEditor("PreviewRestFileNameExtensions"): 235 Preferences.getEditor("PreviewRestFileNameExtensions"):
236 language = "ReST" 236 language = "ReST"
237 else: 237 else:
238 self.__setHtml(fn, self.trUtf8( 238 self.__setHtml(fn, self.tr(
239 "<p>No preview available for this type of file.</p>")) 239 "<p>No preview available for this type of file.</p>"))
240 return 240 return
241 241
242 if fn: 242 if fn:
243 project = e5App().getObject("Project") 243 project = e5App().getObject("Project")
273 Private slot to handle a change of the title. 273 Private slot to handle a change of the title.
274 274
275 @param title new title (string) 275 @param title new title (string)
276 """ 276 """
277 if title: 277 if title:
278 self.titleLabel.setText(self.trUtf8("Preview - {0}").format(title)) 278 self.titleLabel.setText(self.tr("Preview - {0}").format(title))
279 else: 279 else:
280 self.titleLabel.setText(self.trUtf8("Preview")) 280 self.titleLabel.setText(self.tr("Preview"))
281 281
282 def __saveScrollBarPositions(self): 282 def __saveScrollBarPositions(self):
283 """ 283 """
284 Private method to save scroll bar positions for a previewed editor. 284 Private method to save scroll bar positions for a previewed editor.
285 """ 285 """
415 elif language == "Markdown": 415 elif language == "Markdown":
416 return self.__convertMarkdown(text) 416 return self.__convertMarkdown(text)
417 elif language == "ReST": 417 elif language == "ReST":
418 return self.__convertReST(text) 418 return self.__convertReST(text)
419 else: 419 else:
420 return self.trUtf8( 420 return self.tr(
421 "<p>No preview available for this type of file.</p>") 421 "<p>No preview available for this type of file.</p>")
422 422
423 def __processSSI(self, txt, filename, root): 423 def __processSSI(self, txt, filename, root):
424 """ 424 """
425 Private method to process the given text for SSI statements. 425 Private method to process the given text for SSI statements.
475 @return processed HTML (string) 475 @return processed HTML (string)
476 """ 476 """
477 try: 477 try:
478 import docutils.core # __IGNORE_EXCEPTION__ __IGNORE_WARNING__ 478 import docutils.core # __IGNORE_EXCEPTION__ __IGNORE_WARNING__
479 except ImportError: 479 except ImportError:
480 return self.trUtf8( 480 return self.tr(
481 """<p>ReStructuredText preview requires the""" 481 """<p>ReStructuredText preview requires the"""
482 """ <b>python-docutils</b> package.<br/>Install it with""" 482 """ <b>python-docutils</b> package.<br/>Install it with"""
483 """ your package manager or see""" 483 """ your package manager or see"""
484 """ <a href="http://pypi.python.org/pypi/docutils">""" 484 """ <a href="http://pypi.python.org/pypi/docutils">"""
485 """this page.</a></p>""") 485 """this page.</a></p>""")
495 @return processed HTML (string) 495 @return processed HTML (string)
496 """ 496 """
497 try: 497 try:
498 import markdown # __IGNORE_EXCEPTION__ __IGNORE_WARNING__ 498 import markdown # __IGNORE_EXCEPTION__ __IGNORE_WARNING__
499 except ImportError: 499 except ImportError:
500 return self.trUtf8( 500 return self.tr(
501 """<p>Markdown preview requires the <b>python-markdown</b> """ 501 """<p>Markdown preview requires the <b>python-markdown</b> """
502 """package.<br/>Install it with your package manager or see """ 502 """package.<br/>Install it with your package manager or see """
503 """<a href="http://pythonhosted.org/Markdown/install.html">""" 503 """<a href="http://pythonhosted.org/Markdown/install.html">"""
504 """installation instructions.</a></p>""") 504 """installation instructions.</a></p>""")
505 505

eric ide

mercurial