16 import sys |
16 import sys |
17 import io |
17 import io |
18 |
18 |
19 from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QUrl, QThread |
19 from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QUrl, QThread |
20 from PyQt5.QtGui import QCursor |
20 from PyQt5.QtGui import QCursor |
21 from PyQt5.QtWidgets import QWidget, QVBoxLayout, QLabel, QCheckBox, \ |
21 from PyQt5.QtWidgets import ( |
22 QSizePolicy, QToolTip |
22 QWidget, QVBoxLayout, QLabel, QCheckBox, QSizePolicy, QToolTip |
|
23 ) |
23 |
24 |
24 from E5Gui.E5Application import e5App |
25 from E5Gui.E5Application import e5App |
25 |
26 |
26 import Utilities |
27 import Utilities |
27 import Preferences |
28 import Preferences |
170 |
171 |
171 if fn: |
172 if fn: |
172 extension = os.path.normcase(os.path.splitext(fn)[1][1:]) |
173 extension = os.path.normcase(os.path.splitext(fn)[1][1:]) |
173 else: |
174 else: |
174 extension = "" |
175 extension = "" |
175 if extension in \ |
176 if ( |
176 Preferences.getEditor("PreviewHtmlFileNameExtensions") or \ |
177 extension in Preferences.getEditor( |
177 editor.getLanguage() == "HTML": |
178 "PreviewHtmlFileNameExtensions") or |
|
179 editor.getLanguage() == "HTML" |
|
180 ): |
178 language = "HTML" |
181 language = "HTML" |
179 elif extension in \ |
182 elif ( |
180 Preferences.getEditor("PreviewMarkdownFileNameExtensions") or \ |
183 extension in Preferences.getEditor( |
181 editor.getLanguage().lower() == "markdown": |
184 "PreviewMarkdownFileNameExtensions") or |
|
185 editor.getLanguage().lower() == "markdown" |
|
186 ): |
182 language = "Markdown" |
187 language = "Markdown" |
183 elif extension in \ |
188 elif ( |
184 Preferences.getEditor("PreviewRestFileNameExtensions") or \ |
189 extension in Preferences.getEditor( |
185 editor.getLanguage().lower() == "restructuredtext": |
190 "PreviewRestFileNameExtensions") or |
|
191 editor.getLanguage().lower() == "restructuredtext" |
|
192 ): |
186 language = "ReST" |
193 language = "ReST" |
187 else: |
194 else: |
188 self.__setHtml(fn, self.tr( |
195 self.__setHtml(fn, self.tr( |
189 "<p>No preview available for this type of file.</p>")) |
196 "<p>No preview available for this type of file.</p>")) |
190 return |
197 return |
649 extensions = ['fenced_code', 'nl2br', 'extra'] |
656 extensions = ['fenced_code', 'nl2br', 'extra'] |
650 else: |
657 else: |
651 extensions = ['fenced_code', 'extra'] |
658 extensions = ['fenced_code', 'extra'] |
652 |
659 |
653 # version 2.0 supports only extension names, not instances |
660 # version 2.0 supports only extension names, not instances |
654 if markdown.version_info[0] > 2 or \ |
661 if ( |
655 (markdown.version_info[0] == 2 and |
662 markdown.version_info[0] > 2 or |
656 markdown.version_info[1] > 0): |
663 (markdown.version_info[0] == 2 and |
|
664 markdown.version_info[1] > 0) |
|
665 ): |
657 class _StrikeThroughExtension(markdown.Extension): |
666 class _StrikeThroughExtension(markdown.Extension): |
658 """ |
667 """ |
659 Class is placed here, because it depends on imported markdown, |
668 Class is placed here, because it depends on imported markdown, |
660 and markdown import is lazy. |
669 and markdown import is lazy. |
661 |
670 |