mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
c40483eb86
commit
67a168edae
@ -31,13 +31,19 @@ from calibre.utils.titlecase import titlecase
|
||||
PARAGRAPH_SEPARATOR = '\u2029'
|
||||
|
||||
def get_highlighter(syntax):
|
||||
# Load these highlighters only on demand
|
||||
try:
|
||||
ans = importlib.import_module('calibre.gui2.tweak_book.editor.syntax.' + syntax).Highlighter
|
||||
except (ImportError, AttributeError):
|
||||
ans = SyntaxHighlighter
|
||||
return ans
|
||||
|
||||
def get_smarts(syntax):
|
||||
smartsname = {'xml':'html'}.get(syntax, syntax)
|
||||
try:
|
||||
return importlib.import_module('calibre.gui2.tweak_book.editor.smart.' + smartsname).Smarts
|
||||
except (ImportError, AttributeError):
|
||||
pass
|
||||
|
||||
_dff = None
|
||||
def default_font_family():
|
||||
global _dff
|
||||
@ -210,12 +216,8 @@ class TextEdit(PlainTextEdit):
|
||||
self.highlighter = get_highlighter(syntax)()
|
||||
self.highlighter.apply_theme(self.theme)
|
||||
self.highlighter.set_document(self.document(), doc_name=doc_name)
|
||||
smartsname = {'xml':'html'}.get(syntax, syntax)
|
||||
try:
|
||||
sclass = importlib.import_module('calibre.gui2.tweak_book.editor.smart.' + smartsname).Smarts
|
||||
except (ImportError, AttributeError):
|
||||
pass
|
||||
else:
|
||||
sclass = get_smarts(syntax)
|
||||
if sclass is not None:
|
||||
self.smarts = sclass(self)
|
||||
self.setPlainText(unicodedata.normalize('NFC', unicode(text)))
|
||||
if process_template and QPlainTextEdit.find(self, '%CURSOR%'):
|
||||
|
Loading…
x
Reference in New Issue
Block a user