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

Fix conflicting CSS on syntax highlighted blocks #6991

Merged
merged 1 commit into from
Oct 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions res/css/views/rooms/_EventTile.scss
Original file line number Diff line number Diff line change
Expand Up @@ -589,10 +589,6 @@ $hover-select-border: 4px;
padding: 0 10px;
}

.mx_EventTile_content .markdown-body .hljs {
display: inline !important;
}

/*
// actually, removing the Italic TTF provides
// better results seemingly
Expand Down
7 changes: 5 additions & 2 deletions src/components/views/messages/TextualBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ export default class TextualBody extends React.Component<IBodyProps, IState> {
);
return;
}
console.log('highlighting');

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

Expand Down