Use window.$ to make VSCode syntax highlighting play nice

This commit is contained in:
Francis Lavoie 2023-09-07 14:18:30 -04:00
parent 2639f28a27
commit f10b1e85f1
No known key found for this signature in database
GPG key ID: 0F66EE1687682239
8 changed files with 24 additions and 24 deletions

View file

@ -3,26 +3,26 @@ title: Request matchers (Caddyfile)
---
<script>
$(function() {
window.$(function() {
// We'll add links on the matchers in the code blocks
// to their associated anchor tags.
let headers = $('article h3').map((i, el) => el.id.replace(/-/g, "_")).toArray();
$('pre.chroma .k')
window.$('pre.chroma .k')
.filter((k, item) => headers.includes(item.innerText))
.map(function(k, item) {
let text = item.innerText.replace(/</g,'&lt;').replace(/>/g,'&gt;');
let url = '#' + item.innerText.replace(/_/g, "-");
$(item).html('<a href="' + url + '" style="color: inherit;" title="' + text + '">' + text + '</a>');
window.$(item).html(`<a href="${url}" style="color: inherit;" title="${text}">${text}</a>`);
});
// Link matcher tokens based on their contents to the syntax section
$('pre.chroma .nd')
window.$('pre.chroma .nd')
.map(function(k, item) {
let text = item.innerText.replace(/</g,'&lt;').replace(/>/g,'&gt;');
let anchor = "named-matchers"
if (text == "*") anchor = "wildcard-matchers"
if (text.startsWith('/')) anchor = "path-matchers"
$(item).html('<a href="#' + anchor + '" style="color: inherit;" title="Matcher token">' + text + '</a>');
window.$(item).html(`<a href="#${anchor}" style="color: inherit;" title="Matcher token">${text}</a>`);
});
});
</script>