mirror of
https://github.com/caddyserver/website.git
synced 2025-04-24 14:06:17 -04:00
Use window.$ to make VSCode syntax highlighting play nice
This commit is contained in:
parent
2639f28a27
commit
f10b1e85f1
8 changed files with 24 additions and 24 deletions
|
@ -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,'<').replace(/>/g,'>');
|
||||
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,'<').replace(/>/g,'>');
|
||||
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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue