This commit is contained in:
Kovid Goyal 2014-11-21 17:46:28 +05:30
parent 872827f817
commit 288c3a285f

View File

@ -31,6 +31,7 @@ from calibre.utils.titlecase import titlecase
PARAGRAPH_SEPARATOR = '\u2029' PARAGRAPH_SEPARATOR = '\u2029'
def get_highlighter(syntax): def get_highlighter(syntax):
if syntax:
try: try:
return importlib.import_module('calibre.gui2.tweak_book.editor.syntax.' + syntax).Highlighter return importlib.import_module('calibre.gui2.tweak_book.editor.syntax.' + syntax).Highlighter
except (ImportError, AttributeError): except (ImportError, AttributeError):
@ -38,6 +39,7 @@ def get_highlighter(syntax):
return SyntaxHighlighter return SyntaxHighlighter
def get_smarts(syntax): def get_smarts(syntax):
if syntax:
smartsname = {'xml':'html'}.get(syntax, syntax) smartsname = {'xml':'html'}.get(syntax, syntax)
try: try:
return importlib.import_module('calibre.gui2.tweak_book.editor.smarts.' + smartsname).Smarts return importlib.import_module('calibre.gui2.tweak_book.editor.smarts.' + smartsname).Smarts