mirror of
https://github.com/nix-community/home-manager.git
synced 2025-12-07 01:21:03 +01:00
deploy: 2c29ae48f9
This commit is contained in:
parent
6ec883e4c6
commit
1a571e4e35
14 changed files with 398 additions and 375 deletions
|
|
@ -1,6 +1,35 @@
|
|||
/* This file is NOT part of highlight.js */
|
||||
|
||||
class PreserveCallouts {
|
||||
|
||||
constructor(options) {
|
||||
self.callouts = [];
|
||||
/* Using OBJECT REPLACEMENT CHARACTER as a marker of where the callout
|
||||
should be inserted. We hope that this won't cause conflicts. */
|
||||
self.marker = '\u{FFFC}';
|
||||
}
|
||||
|
||||
'before:highlightElement'({el, language}) {
|
||||
const re = /<a id="[^"]+"><\/a><span><img src="images\/callouts\/\d+.svg" alt="\d+" border="0"><\/span>/g;
|
||||
const array = [...el.innerHTML.matchAll(re)];
|
||||
if (array.length > 0) {
|
||||
self.callouts = array;
|
||||
el.innerHTML = el.innerHTML.replaceAll(re, self.marker);
|
||||
}
|
||||
}
|
||||
|
||||
'after:highlightElement'({ el, result, text }) {
|
||||
if (self.callouts.length > 0) {
|
||||
el.innerHTML = el.innerHTML.replaceAll(
|
||||
self.marker, (str) => self.callouts.shift());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', (event) => {
|
||||
document.querySelectorAll('pre.programlisting, pre.screen').forEach((block) => {
|
||||
hljs.highlightBlock(block);
|
||||
hljs.addPlugin(new PreserveCallouts());
|
||||
|
||||
document.querySelectorAll('pre.programlisting, pre.screen').forEach((el) => {
|
||||
hljs.highlightElement(el);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue