@xiee/utils
Version:
Miscellaneous tools and utilities to manipulate HTML pages
11 lines (10 loc) • 516 B
JavaScript
// move the class from <pre class="foo"> (generated by Pandoc with --no-highlight)
// to <code class="language-foo"> so that Prism.js can highlight the code
document.querySelectorAll('pre[class]:not([class^=language-])').forEach(el => {
el.firstElementChild?.classList.add(`language-${el.classList[0]}`);
el.removeAttribute('class');
});
document.querySelectorAll('table').forEach(el => {
el.getAttribute('style') === 'width:100%;' && el.removeAttribute('style');
el.querySelector('colgroup')?.remove();
});