Setting consistent highlighting for code blocks and inline code #11910
Replies: 4 comments 2 replies
-
Could you try using plain Pandoc? (I don't think Quarto does anything here.) |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Thank you so much already for all the information. Is there anything I can still do from my side to help with this? |
Beta Was this translation helpful? Give feedback.
-
Just played around a bit to find some quick fix for now. Including the following script using document.addEventListener('DOMContentLoaded', () => {
// Select all <code> elements in the document
const codeElements = document.querySelectorAll('code');
codeElements.forEach((codeElement) => {
// Check if the <code> element does not have a <pre> parent
if (codeElement.parentElement.tagName.toLowerCase() !== 'pre') {
// Create a new <span> element
const spanElement = document.createElement('span');
// Move all child nodes of <code> into the new <span> element
while (codeElement.firstChild) {
spanElement.appendChild(codeElement.firstChild);
}
// Append the <span> as the first child of the <code> element
codeElement.appendChild(spanElement);
}
});
}); I additionally changes the background color to |
Beta Was this translation helpful? Give feedback.
-
Description
I just noticed that the highlighting style of inline code and code blocks is entirely different. Is there some way to achieve a consistent highlighting style.
Example:
The code block is correctly formatted using the GitHub style (as much as I can see), but the inline code has a completely different highlighting.
From what I can see in the produced html and css, this seems to be the case because there is a span missing right after the code opening. The current html for the inline code is something like
If I change this to
then the highlighting is correct, only the background is still wrong. Is there some way I can achieve this without some additional javascript?
Beta Was this translation helpful? Give feedback.
All reactions