From cd125506b6dfad14dd3f2a37632bb9eacb5a358b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Sun, 11 Jul 2021 11:18:06 +0200 Subject: [PATCH] Auto-detect language only if enabled and only for codeblocks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/components/views/messages/TextualBody.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/views/messages/TextualBody.tsx b/src/components/views/messages/TextualBody.tsx index 9c2786c642..9009b9ee1b 100644 --- a/src/components/views/messages/TextualBody.tsx +++ b/src/components/views/messages/TextualBody.tsx @@ -244,7 +244,11 @@ export default class TextualBody extends React.Component { } private highlightCode(code: HTMLElement): void { - if (SettingsStore.getValue("enableSyntaxHighlightLanguageDetection")) { + // Auto-detect language only if enabled and only for codeblocks + if ( + SettingsStore.getValue("enableSyntaxHighlightLanguageDetection") && + code.parentElement instanceof HTMLPreElement + ) { highlight.highlightBlock(code); } else { // Only syntax highlight if there's a class starting with language-