Created
February 25, 2023 17:45
-
-
Save dKvale/062fafe09c5ce605f5a8d0fff4cad1b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// apply pandoc div.sourceCode style to pre.sourceCode instead | |
(function() { | |
var sheets = document.styleSheets; | |
for (var i = 0; i < sheets.length; i++) { | |
if (sheets[i].ownerNode.dataset["origin"] !== "pandoc") continue; | |
try { var rules = sheets[i].cssRules; } catch (e) { continue; } | |
var j = 0; | |
while (j < rules.length) { | |
var rule = rules[j]; | |
// check if there is a div.sourceCode rule | |
if (rule.type !== rule.STYLE_RULE || rule.selectorText !== "div.sourceCode") { | |
j++; | |
continue; | |
} | |
var style = rule.style.cssText; | |
// check if color or background-color is set | |
if (rule.style.color === '' && rule.style.backgroundColor === '') { | |
j++; | |
continue; | |
} | |
// replace div.sourceCode by a pre.sourceCode rule | |
sheets[i].deleteRule(j); | |
sheets[i].insertRule('pre.sourceCode{' + style + '}', j); | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment