Code: Fixed highlighting issues when no code language set

For #4917
This commit is contained in:
Dan Brown 2024-03-31 14:33:08 +01:00
parent 0d3de40459
commit 58f6219cb3
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9

View File

@ -48,14 +48,16 @@ function highlightElem(elem) {
const content = elem.textContent.trimEnd();
let langName = '';
let innerCodeDirection = '';
if (innerCodeElem !== null) {
langName = innerCodeElem.className.replace('language-', '');
innerCodeDirection = innerCodeElem.getAttribute('dir');
}
const wrapper = document.createElement('div');
elem.parentNode.insertBefore(wrapper, elem);
const direction = innerCodeElem.getAttribute('dir') || elem.getAttribute('dir') || '';
const direction = innerCodeDirection || elem.getAttribute('dir') || '';
if (direction) {
wrapper.setAttribute('dir', direction);
}