def get_highlighter(parent, text, syntax): hlclass = calibre_highlighter(syntax) if hlclass is SyntaxHighlighter: filename = os.path.basename(parent.headers[-1][1]) lexer = pygments_lexer(filename) if lexer is None: return NullHighlighter(text) return PygmentsHighlighter(text, lexer) return QtHighlighter(parent, text, hlclass)
def get_highlighter(parent, text, syntax): hlclass = calibre_highlighter(syntax) if hlclass is SyntaxHighlighter: filename = os.path.basename(parent.headers[-1][1]) lexer = pygments_lexer(filename) if lexer is None: return NullHighlighter(text) return PygmentsHighlighter(text, lexer) return QtHighlighter(parent, text, hlclass)