Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit b16af66

Browse files
dbkrRiotRobot
authored andcommitted
Fix conflicting CSS on syntax highlighted blocks (#6991)
Fixes element-hq/element-web#19445
1 parent 10ed592 commit b16af66

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

res/css/views/rooms/_EventTile.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -589,10 +589,6 @@ $hover-select-border: 4px;
589589
padding: 0 10px;
590590
}
591591

592-
.mx_EventTile_content .markdown-body .hljs {
593-
display: inline !important;
594-
}
595-
596592
/*
597593
// actually, removing the Italic TTF provides
598594
// better results seemingly

src/components/views/messages/TextualBody.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ export default class TextualBody extends React.Component<IBodyProps, IState> {
232232
);
233233
return;
234234
}
235-
console.log('highlighting');
236235

237236
let advertisedLang;
238237
for (const cl of code.className.split(/\s+/)) {
@@ -258,7 +257,11 @@ export default class TextualBody extends React.Component<IBodyProps, IState> {
258257
// User has language detection enabled and the code is within a pre
259258
// we only auto-highlight if the code block is in a pre), so highlight
260259
// the block with auto-highlighting enabled.
261-
highlight.highlightElement(code);
260+
// We pass highlightjs the text to highlight rather than letting it
261+
// work on the DOM with highlightElement because that also adds CSS
262+
// classes to the pre/code element that we don't want (the CSS
263+
// conflicts with our own).
264+
code.innerHTML = highlight.highlightAuto(code.textContent).value;
262265
}
263266
}
264267

0 commit comments

Comments
 (0)