You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
891 B
JavaScript
21 lines
891 B
JavaScript
document.addEventListener("DOMContentLoaded", function() {
|
|
document.querySelectorAll('.code-source').forEach(function(marker) {
|
|
let sourceUrl = marker.getAttribute('data-source');
|
|
let nextPre = marker.nextElementSibling;
|
|
|
|
if (nextPre && nextPre.tagName === 'PRE') {
|
|
let codeElement = nextPre.querySelector('code');
|
|
if (codeElement) {
|
|
// Use a span element for the source path if it's not a link.
|
|
let sourceElement = document.createElement(sourceUrl.startsWith('http') ? 'a' : 'span');
|
|
sourceElement.textContent = sourceUrl;
|
|
sourceElement.className = 'source-path';
|
|
if (sourceUrl.startsWith('http')) {
|
|
sourceElement.href = sourceUrl;
|
|
}
|
|
codeElement.prepend(sourceElement);
|
|
}
|
|
}
|
|
});
|
|
});
|