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-