Skip to content

Instantly share code, notes, and snippets.

@dKvale
Created February 25, 2023 17:45
Show Gist options
  • Save dKvale/062fafe09c5ce605f5a8d0fff4cad1b6 to your computer and use it in GitHub Desktop.
Save dKvale/062fafe09c5ce605f5a8d0fff4cad1b6 to your computer and use it in GitHub Desktop.
// 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