From 288c3a285fb90d5b190ba0612ae51bdb28cfb3c9 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 21 Nov 2014 17:46:28 +0530 Subject: [PATCH] ... --- src/calibre/gui2/tweak_book/editor/text.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/calibre/gui2/tweak_book/editor/text.py b/src/calibre/gui2/tweak_book/editor/text.py index a4c3206d6b..5af765338f 100644 --- a/src/calibre/gui2/tweak_book/editor/text.py +++ b/src/calibre/gui2/tweak_book/editor/text.py @@ -31,18 +31,20 @@ from calibre.utils.titlecase import titlecase PARAGRAPH_SEPARATOR = '\u2029' def get_highlighter(syntax): - try: - return importlib.import_module('calibre.gui2.tweak_book.editor.syntax.' + syntax).Highlighter - except (ImportError, AttributeError): - pass + if syntax: + try: + return importlib.import_module('calibre.gui2.tweak_book.editor.syntax.' + syntax).Highlighter + except (ImportError, AttributeError): + pass return SyntaxHighlighter def get_smarts(syntax): - smartsname = {'xml':'html'}.get(syntax, syntax) - try: - return importlib.import_module('calibre.gui2.tweak_book.editor.smarts.' + smartsname).Smarts - except (ImportError, AttributeError): - pass + if syntax: + smartsname = {'xml':'html'}.get(syntax, syntax) + try: + return importlib.import_module('calibre.gui2.tweak_book.editor.smarts.' + smartsname).Smarts + except (ImportError, AttributeError): + pass _dff = None def default_font_family():