From 78cce3373a4c00c98d1d797df1b6bb637695eb77 Mon Sep 17 00:00:00 2001 From: George Melikov Date: Sun, 14 Sep 2025 15:02:34 +0300 Subject: [PATCH 1/3] Support .md links with anchors Signed-off-by: George Melikov --- _layouts/page.html | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/_layouts/page.html b/_layouts/page.html index db12fe1..a86f41a 100755 --- a/_layouts/page.html +++ b/_layouts/page.html @@ -102,11 +102,21 @@

{{ page.title }}

linktext = links[i][0] linktitle = links[i][2] link = links[i][3] - + + // Links may have anchors + parsed_link = link.split('#', 2) + link = parsed_link[0] + anchor = parsed_link[1] + if (link.endsWith(".md") && !link.startsWith("http")) { // Prepare a variant of the link to sub in - linkUpdated = {% if page.parent %}"{{ site.baseurl }}/{{ page.parent }}/" + {% endif %} basename(link).replace(".md") + "/?v=" + window.version + linkUpdated = {% if page.parent %}"{{ site.baseurl }}/{{ page.parent }}/" + {% endif %} basename(link).replace(".md") + "/?v=" + window.version + + if (anchor) { + linkUpdated = linkUpdated + '#' + anchor + } + // assemble the new link in entirety linkUpdated = "" + linktitle + "" console.log("Replacing " + linktext + " with " + linkUpdated) @@ -146,6 +156,7 @@

{{ page.title }}

} $(this).append("") }); + }); }); From edf6a07b24f5483ca8a7cf86da5ce4ae03f7aec0 Mon Sep 17 00:00:00 2001 From: George Melikov Date: Sun, 14 Sep 2025 15:03:25 +0300 Subject: [PATCH 2/3] Scroll to anchors after target page load Signed-off-by: George Melikov --- _layouts/page.html | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/_layouts/page.html b/_layouts/page.html index a86f41a..8f4e2b6 100755 --- a/_layouts/page.html +++ b/_layouts/page.html @@ -157,6 +157,14 @@

{{ page.title }}

$(this).append("") }); + // Scroll to anchor + if (window.location.hash) { + const targetElement = document.querySelector(window.location.hash); + if (targetElement) { + targetElement.scrollIntoView({ behavior: 'smooth', block: 'start' }); + } + } + }); }); From 85c54df041aa708cbb4b344941e5d64f10998438 Mon Sep 17 00:00:00 2001 From: George Melikov Date: Sun, 14 Sep 2025 15:03:51 +0300 Subject: [PATCH 3/3] page.html: cleanup trailing spaces Signed-off-by: George Melikov --- _layouts/page.html | 24 ++++++++++++------------ assets/css/main.css | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/_layouts/page.html b/_layouts/page.html index 8f4e2b6..f87a50a 100755 --- a/_layouts/page.html +++ b/_layouts/page.html @@ -32,8 +32,8 @@

{{ page.title }}

// 'Configuration', 'href="config.md"', "Configuration" ] const links = []; let img; - while ((img = imgRex.exec(string))) { - // Parse the second component without href and add to array + while ((img = imgRex.exec(string))) { + // Parse the second component without href and add to array cleaned = img[1].replace("href=", "").replaceAll('"', '') img.push(cleaned) links.push(img); @@ -42,8 +42,8 @@

{{ page.title }}

} function basename(str) { - var base = new String(str).substring(str.lastIndexOf('/') + 1); - if(base.lastIndexOf(".") != -1) + var base = new String(str).substring(str.lastIndexOf('/') + 1); + if(base.lastIndexOf(".") != -1) base = base.substring(0, base.lastIndexOf(".")); return base; } @@ -77,7 +77,7 @@

{{ page.title }}

// Get GitHub stars and forks for the repo var url = "https://api.github.com/search/repositories?q={{ site.data.specs[page.key].github_repo }}"; - fetch(url, { + fetch(url, { headers: {"Accept":"application/vnd.github.preview"} }).then(function(e) { return e.json() @@ -95,12 +95,12 @@

{{ page.title }}

html = converter.makeHtml(data); // Find all relative markdown links and replace with pages - var links = getLinks(html) + var links = getLinks(html) for (var i = 0; i < links.length; i++) { - + // Full link text to replace - linktext = links[i][0] - linktitle = links[i][2] + linktext = links[i][0] + linktitle = links[i][2] link = links[i][3] // Links may have anchors @@ -120,7 +120,7 @@

{{ page.title }}

// assemble the new link in entirety linkUpdated = "" + linktitle + "" console.log("Replacing " + linktext + " with " + linkUpdated) - html = html.replace(linktext, linkUpdated) + html = html.replace(linktext, linkUpdated) } } @@ -131,9 +131,9 @@

{{ page.title }}

image = images[i]; if (!image.startsWith("http")) { html = html.replace(image, "https://raw.githubusercontent.com/{{ site.data.specs[page.key].github_repo }}/" + window.version + "/" + image); - } + } } - + $('#content').html(html) $('#content').show(); diff --git a/assets/css/main.css b/assets/css/main.css index ecb54a5..fa3ef89 100644 --- a/assets/css/main.css +++ b/assets/css/main.css @@ -169,7 +169,7 @@ dl > dt { float: left; margin-right: 1em; } -/* +/* dl.nohang > dt { float: none; }