diff --git a/tildes/tildes/lib/markdown.py b/tildes/tildes/lib/markdown.py index e1f860f..f600351 100644 --- a/tildes/tildes/lib/markdown.py +++ b/tildes/tildes/lib/markdown.py @@ -206,13 +206,12 @@ def apply_syntax_highlighting(html: str) -> str: language = code_block["class"][0].replace("language-", "") try: + lexer = get_lexer_by_name(language) # If target language is PHP, override default lexer construction # and set startinline to True, so even code that is not enclosed # inside will get highlighted. - if language in ["php", "php3", "php4", "php5"]: + if isinstance(lexer, PhpLexer): lexer = PhpLexer(startinline=True) - else: - lexer = get_lexer_by_name(language) except ClassNotFound: continue