fix #91 syntax highlighting of kotlin code blocks on the site

This commit is contained in:
Sergey Chernov 2025-12-08 18:51:44 +01:00
parent 708b908415
commit 8750040926

View File

@ -17,291 +17,446 @@
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Lyng language</title> <title>Lyng language</title>
<!-- Site favicon (SVG, adapts to light/dark) --> <!-- Site favicon (SVG, adapts to light/dark) -->
<link rel="icon" type="image/svg+xml" href="icons/lyng-favicon.svg" /> <link rel="icon" type="image/svg+xml" href="icons/lyng-favicon.svg"/>
<!-- GitHub Markdown CSS (light and dark). We toggle these from the app. --> <!-- GitHub Markdown CSS (light and dark). We toggle these from the app. -->
<link <link
id="md-light" id="md-light"
rel="stylesheet" rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/github-markdown-css@5.4.0/github-markdown.css" href="https://cdn.jsdelivr.net/npm/github-markdown-css@5.4.0/github-markdown.css"
/> />
<link <link
id="md-dark" id="md-dark"
rel="stylesheet" rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/github-markdown-css@5.4.0/github-markdown-dark.css" href="https://cdn.jsdelivr.net/npm/github-markdown-css@5.4.0/github-markdown-dark.css"
disabled disabled
/> />
<!-- Bootstrap 5.3 CSS --> <!-- Bootstrap 5.3 CSS -->
<link <link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
rel="stylesheet" rel="stylesheet"
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"
crossorigin="anonymous" crossorigin="anonymous"
/> />
<!-- Bootstrap Icons --> <!-- Bootstrap Icons -->
<link <link
rel="stylesheet" rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css"
/> />
<!-- MathJax v3 configuration (the loader is bundled via npm/webpack) --> <!-- MathJax v3 configuration (the loader is bundled via npm/webpack) -->
<script> <script>
window.MathJax = { window.MathJax = {
tex: { tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']], inlineMath: [['$', '$'], ['\\(', '\\)']],
displayMath: [['$$', '$$'], ['\\[', '\\]']], displayMath: [['$$', '$$'], ['\\[', '\\]']],
processEscapes: true processEscapes: true
}, },
options: { options: {
skipHtmlTags: ['script','noscript','style','textarea','pre','code'] skipHtmlTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
}, },
startup: { startup: {
// We'll trigger typesetting manually from the app after markdown is mounted // We'll trigger typesetting manually from the app after markdown is mounted
typeset: false typeset: false
} }
}; };
</script> </script>
<!-- Loader is imported in the app bundle; no external script tag required --> <!-- Loader is imported in the app bundle; no external script tag required -->
<style> <style>
/* Reserve space for fixed navbar and ensure in-page anchors don't end up hidden under it */ /* Reserve space for fixed navbar and ensure in-page anchors don't end up hidden under it */
:root { --navbar-offset: 56px; } :root {
body { --navbar-offset: 56px;
/* Fallback padding; JS will keep this equal to the real navbar height */ }
/*padding-top: var(--navbar-offset);*/
/* Make native hash jumps account for the fixed header */ body {
/*scroll-padding-top: calc(var(--navbar-offset) + 8px);*/ /* Fallback padding; JS will keep this equal to the real navbar height */
} /*padding-top: var(--navbar-offset);*/
/* Also offset scroll for headings and any element targeted by an id */ /* Make native hash jumps account for the fixed header */
.markdown-body h1, /*scroll-padding-top: calc(var(--navbar-offset) + 8px);*/
.markdown-body h2, }
.markdown-body h3,
.markdown-body h4, /* Also offset scroll for headings and any element targeted by an id */
.markdown-body h5, .markdown-body h1,
.markdown-body h6, .markdown-body h2,
[id] { .markdown-body h3,
/*scroll-margin-top: calc(var(--navbar-offset) + 8px);*/ .markdown-body h4,
} .markdown-body h5,
/* Unify markdown and page backgrounds with Bootstrap theme variables */ .markdown-body h6,
.markdown-body { [id] {
box-sizing: border-box; /*scroll-margin-top: calc(var(--navbar-offset) + 8px);*/
min-width: 200px; }
line-height: 1.6;
background: var(--bs-body-bg) !important; /* Unify markdown and page backgrounds with Bootstrap theme variables */
color: var(--bs-body-color) !important; .markdown-body {
} box-sizing: border-box;
.markdown-body > :first-child { margin-top: 0 !important; } min-width: 200px;
.markdown-body table { margin: 1rem 0; } line-height: 1.6;
.markdown-body pre { background: var(--bs-body-bg) !important;
padding: .75rem; color: var(--bs-body-color) !important;
border-radius: .375rem; }
background: var(--bs-tertiary-bg);
border: 1px solid var(--bs-border-color); .markdown-body > :first-child {
} margin-top: 0 !important;
/* Style only inline code, avoid affecting code blocks inside <pre> to prevent first-line extra indent */ }
.markdown-body :not(pre) > code:not([class]) {
background: var(--bs-tertiary-bg); .markdown-body table {
padding: .15rem .3rem; margin: 1rem 0;
border-radius: .25rem; }
}
.markdown-body pre {
/* Lyng syntax highlighting palette (inspired by default GitHub/VS Code) */ padding: .75rem;
/* Light theme */ border-radius: .375rem;
.hl-kw { color: #d73a49; font-weight: 600; } background: var(--bs-tertiary-bg);
.hl-ty { color: #6f42c1; } border: 1px solid var(--bs-border-color);
.hl-id { color: #24292e; } }
/* Declarations (semantic roles) */
.hl-fn { color: #005cc5; font-weight: 600; } /* Style only inline code, avoid affecting code blocks inside <pre> to prevent first-line extra indent */
.hl-class { color: #5a32a3; font-weight: 600; } .markdown-body :not(pre) > code:not([class]) {
.hl-val { color: #1b7f5a; } background: var(--bs-tertiary-bg);
.hl-var { color: #1b7f5a; text-decoration: underline dotted currentColor; } padding: .15rem .3rem;
.hl-enumc { color: #b08800; font-weight: 600; } border-radius: .25rem;
.hl-param { color: #0969da; font-style: italic; } }
.hl-num { color: #005cc5; }
.hl-str { color: #032f62; } /* Lyng syntax highlighting palette (inspired by default GitHub/VS Code) */
.hl-ch { color: #032f62; } /* Light theme */
.hl-rx { color: #116329; } .hl-kw {
.hl-cmt { color: #6a737d; font-style: italic; } color: #d73a49;
.hl-op { color: #8250df; } font-weight: 600;
.hl-punc{ color: #57606a; } }
.hl-lbl { color: #e36209; }
.hl-dir { color: #6f42c1; } .hl-ty {
.hl-err { color: #b31d28; text-decoration: underline wavy #b31d28; } color: #6f42c1;
}
/* Dark theme overrides (GitHub Dark-like) */
[data-bs-theme="dark"] .hl-id { color: #c9d1d9; } .hl-id {
[data-bs-theme="dark"] .hl-op { color: #d2a8ff; } color: #24292e;
[data-bs-theme="dark"] .hl-punc { color: #8b949e; } }
[data-bs-theme="dark"] .hl-kw { color: #ff7b72; }
[data-bs-theme="dark"] .hl-ty { color: #d2a8ff; } /* Declarations (semantic roles) */
[data-bs-theme="dark"] .hl-fn { color: #79c0ff; font-weight: 700; } .hl-fn {
[data-bs-theme="dark"] .hl-class{ color: #d2a8ff; font-weight: 700; } color: #005cc5;
[data-bs-theme="dark"] .hl-val { color: #7ee787; } font-weight: 600;
[data-bs-theme="dark"] .hl-var { color: #7ee787; text-decoration: underline dotted currentColor; } }
[data-bs-theme="dark"] .hl-enumc{ color: #f2cc60; font-weight: 700; }
[data-bs-theme="dark"] .hl-param{ color: #a5d6ff; font-style: italic; } .hl-class {
[data-bs-theme="dark"] .hl-num { color: #79c0ff; } color: #5a32a3;
[data-bs-theme="dark"] .hl-str, font-weight: 600;
[data-bs-theme="dark"] .hl-ch { color: #a5d6ff; } }
[data-bs-theme="dark"] .hl-rx { color: #7ee787; }
[data-bs-theme="dark"] .hl-cmt { color: #8b949e; } .hl-val {
[data-bs-theme="dark"] .hl-lbl { color: #ffa657; } color: #1b7f5a;
[data-bs-theme="dark"] .hl-dir { color: #d2a8ff; } }
[data-bs-theme="dark"] .hl-err { color: #ffa198; text-decoration-color: #ffa198; }
.hl-var {
/* Top-left corner ribbon for version label */ color: #1b7f5a;
.corner-ribbon { text-decoration: underline dotted currentColor;
position: fixed; }
/* Place below the fixed navbar (Bootstrap fixed-top ~ z-index: 1030) */
z-index: 1020; /* above content, below navbar */ .hl-enumc {
top: var(--navbar-offset, 56px); color: #b08800;
left: 0; font-weight: 600;
width: 242px; /* 10% narrower than 180px */ }
text-align: center;
/* Slightly asymmetric padding to visually center text within rotated band (desktop) */ .hl-param {
/* Nudge text a bit lower on large screens */ color: #0969da;
padding: .42rem 0 .28rem; font-style: italic;
font-weight: 600; }
font-size: .75rem; /* make text smaller by default */
line-height: 1.1; /* stabilize vertical centering */ .hl-num {
transform: translate(-52px, 10px) rotate(-45deg); color: #005cc5;
box-shadow: 0 0.25rem 0.5rem rgba(0,0,0,.2); }
border: 1px solid rgba(0,0,0,.15);
pointer-events: none; /* decorative; don't block clicks underneath */ .hl-str {
} color: #032f62;
@media (max-width: 576px) { }
.corner-ribbon {
width: 195px; /* 10% narrower than 150px */ .hl-ch {
transform: translate(-50px, 8px) rotate(-45deg); color: #032f62;
font-size: .6rem; /* even smaller on phones */ }
padding: .32rem 0 .28rem; /* keep mobile text centered too */
.hl-rx {
color: #116329;
}
.hl-cmt {
color: #6a737d;
font-style: italic;
}
.hl-op {
color: #8250df;
}
.hl-punc {
color: #57606a;
}
.hl-lbl {
color: #e36209;
}
.hl-dir {
color: #6f42c1;
}
.hl-err {
color: #b31d28;
text-decoration: underline wavy #b31d28;
}
/* Dark theme overrides (GitHub Dark-like) */
[data-bs-theme="dark"] .hl-id {
color: #c9d1d9;
}
[data-bs-theme="dark"] .hl-op {
color: #d2a8ff;
}
[data-bs-theme="dark"] .hl-punc {
color: #8b949e;
}
[data-bs-theme="dark"] .hl-kw {
color: #ff7b72;
}
[data-bs-theme="dark"] .hl-ty {
color: #d2a8ff;
}
[data-bs-theme="dark"] .hl-fn {
color: #79c0ff;
font-weight: 700;
}
[data-bs-theme="dark"] .hl-class {
color: #d2a8ff;
font-weight: 700;
}
[data-bs-theme="dark"] .hl-val {
color: #7ee787;
}
[data-bs-theme="dark"] .hl-var {
color: #7ee787;
text-decoration: underline dotted currentColor;
}
[data-bs-theme="dark"] .hl-enumc {
color: #f2cc60;
font-weight: 700;
}
[data-bs-theme="dark"] .hl-param {
color: #a5d6ff;
font-style: italic;
}
[data-bs-theme="dark"] .hl-num {
color: #79c0ff;
}
[data-bs-theme="dark"] .hl-str,
[data-bs-theme="dark"] .hl-ch {
color: #a5d6ff;
}
[data-bs-theme="dark"] .hl-rx {
color: #7ee787;
}
[data-bs-theme="dark"] .hl-cmt {
color: #8b949e;
}
[data-bs-theme="dark"] .hl-lbl {
color: #ffa657;
}
[data-bs-theme="dark"] .hl-dir {
color: #d2a8ff;
}
[data-bs-theme="dark"] .hl-err {
color: #ffa198;
text-decoration-color: #ffa198;
}
/* Top-left corner ribbon for version label */
.corner-ribbon {
position: fixed;
/* Place below the fixed navbar (Bootstrap fixed-top ~ z-index: 1030) */
z-index: 1020; /* above content, below navbar */
top: var(--navbar-offset, 56px);
left: 0;
width: 242px; /* 10% narrower than 180px */
text-align: center;
/* Slightly asymmetric padding to visually center text within rotated band (desktop) */
/* Nudge text a bit lower on large screens */
padding: .42rem 0 .28rem;
font-weight: 600;
font-size: .75rem; /* make text smaller by default */
line-height: 1.1; /* stabilize vertical centering */
transform: translate(-52px, 10px) rotate(-45deg);
box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, .2);
border: 1px solid rgba(0, 0, 0, .15);
pointer-events: none; /* decorative; don't block clicks underneath */
}
@media (max-width: 576px) {
.corner-ribbon {
width: 195px; /* 10% narrower than 150px */
transform: translate(-50px, 8px) rotate(-45deg);
font-size: .6rem; /* even smaller on phones */
padding: .32rem 0 .28rem; /* keep mobile text centered too */
}
} }
}
</style> </style>
</head>
<body> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/styles/dark.min.css">
<!-- Top-left version ribbon --> <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/highlight.min.js"></script>
<div class="corner-ribbon bg-danger text-white"> <!-- and it's easy to individually load additional languages -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/languages/go.min.js"></script>
</head>
<body>
<!-- Top-left version ribbon -->
<div class="corner-ribbon bg-danger text-white">
<span style="margin-left: -5em"> <span style="margin-left: -5em">
v1.0.6-SNAPSHOT v1.0.6-SNAPSHOT
</span> </span>
</div> </div>
<!-- Fixed top navbar for the whole site --> <!-- Fixed top navbar for the whole site -->
<a href="#root" class="visually-hidden-focusable position-absolute top-0 start-0 m-2 px-2 py-1 bg-body border rounded">Skip to content</a> <a href="#root" class="visually-hidden-focusable position-absolute top-0 start-0 m-2 px-2 py-1 bg-body border rounded">Skip
<nav class="navbar navbar-expand-lg bg-body-tertiary fixed-top border-bottom" role="navigation" aria-label="Primary"> to content</a>
<div class="container-fluid"> <nav class="navbar navbar-expand-lg bg-body-tertiary fixed-top border-bottom" role="navigation" aria-label="Primary">
<div class="container-fluid">
<a class="navbar-brand d-flex align-items-center gap-2" href="#"> <a class="navbar-brand d-flex align-items-center gap-2" href="#">
<!-- Inline SVG brand icon: λ with superscript y and subscript ng. Uses currentColor to match theme. --> <!-- Inline SVG brand icon: λ with superscript y and subscript ng. Uses currentColor to match theme. -->
<svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 24 24" role="img" aria-hidden="true"> <svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 24 24" role="img"
<g fill="currentColor" color="inherit" font-family="'STIX Two Math', 'Cambria Math', 'Times New Roman', serif"> aria-hidden="true">
<!-- Main lambda --> <g fill="currentColor" color="inherit"
<text x="3" y="17" font-size="16" font-weight="700">λ</text> font-family="'STIX Two Math', 'Cambria Math', 'Times New Roman', serif">
<!-- Superscript y --> <!-- Main lambda -->
<text x="11.2" y="8" font-size="10">y</text> <text x="3" y="17" font-size="16" font-weight="700">λ</text>
</g> <!-- Superscript y -->
</svg> <text x="11.2" y="8" font-size="10">y</text>
Lyng </g>
</svg>
Lyng
</a> </a>
<button <button
class="navbar-toggler" class="navbar-toggler"
type="button" type="button"
data-bs-toggle="collapse" data-bs-toggle="collapse"
data-bs-target="#topbarNav" data-bs-target="#topbarNav"
aria-controls="topbarNav" aria-controls="topbarNav"
aria-expanded="false" aria-expanded="false"
aria-label="Toggle navigation" aria-label="Toggle navigation"
> >
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
</button> </button>
<div class="collapse navbar-collapse" id="topbarNav"> <div class="collapse navbar-collapse" id="topbarNav">
<!-- Left-aligned main menu --> <!-- Left-aligned main menu -->
<ul class="navbar-nav me-auto mb-2 mb-lg-0"> <ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item dropdown"> <li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#/docs/Iterator.md" role="button" data-bs-toggle="dropdown" aria-expanded="false"> <a class="nav-link dropdown-toggle" href="#/docs/Iterator.md" role="button"
Documentation data-bs-toggle="dropdown" aria-expanded="false">
</a> Documentation
<ul id="docsDropdownMenu" class="dropdown-menu"> </a>
<!-- Will be populated at runtime --> <ul id="docsDropdownMenu" class="dropdown-menu">
<li><a class="dropdown-item" href="#/docs/tutorial.md" data-route="docs">Tutorial</a></li> <!-- Will be populated at runtime -->
<li><a class="dropdown-item" href="#/reference" data-route="reference">Reference</a></li> <li><a class="dropdown-item" href="#/docs/tutorial.md" data-route="docs">Tutorial</a></li>
<li><hr class="dropdown-divider"></li> <li><a class="dropdown-item" href="#/reference" data-route="reference">Reference</a></li>
<li>
<hr class="dropdown-divider">
</li>
</ul> </ul>
</li>
<!-- IDE support dropdown -->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#/docs/idea_plugin.md" role="button" data-bs-toggle="dropdown" aria-expanded="false">
IDE support
</a>
<ul class="dropdown-menu">
<li>
<a class="dropdown-item" href="#/docs/textmate_bundle.md" data-route="docs">Textmate bundle</a>
</li> </li>
<li> <!-- IDE support dropdown -->
<a class="dropdown-item" href="#/docs/idea_plugin.md" data-route="docs">IDEA plugin</a> <li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#/docs/idea_plugin.md" role="button"
data-bs-toggle="dropdown" aria-expanded="false">
IDE support
</a>
<ul class="dropdown-menu">
<li>
<a class="dropdown-item" href="#/docs/textmate_bundle.md" data-route="docs">Textmate
bundle</a>
</li>
<li>
<a class="dropdown-item" href="#/docs/idea_plugin.md" data-route="docs">IDEA plugin</a>
</li>
</ul>
</li> </li>
</ul> <li class="nav-item">
</li> <a class="nav-link" href="#/tryling" data-route="tryling">Try in browser</a>
<li class="nav-item"> </li>
<a class="nav-link" href="#/tryling" data-route="tryling">Try in browser</a> </ul>
</li>
</ul>
<!-- Right utilities: search, GitHub link --> <!-- Right utilities: search, GitHub link -->
<div class="ms-auto d-flex align-items-center gap-2" style="min-width: 240px;"> <div class="ms-auto d-flex align-items-center gap-2" style="min-width: 240px;">
<!-- Search widget with Bootstrap Icons magnifying glass --> <!-- Search widget with Bootstrap Icons magnifying glass -->
<form class="d-flex" role="search" onsubmit="return false;"> <form class="d-flex" role="search" onsubmit="return false;">
<div class="input-group position-relative" style="min-width: 280px;"> <div class="input-group position-relative" style="min-width: 280px;">
<span class="input-group-text bg-transparent border-end-0"> <span class="input-group-text bg-transparent border-end-0">
<i class="bi bi-search"></i> <i class="bi bi-search"></i>
</span> </span>
<input <input
id="topSearch" id="topSearch"
class="form-control border-start-0" class="form-control border-start-0"
type="search" type="search"
placeholder="Search" placeholder="Search"
aria-label="Search" aria-label="Search"
/> />
<!-- Results dropdown (controlled by app code) --> <!-- Results dropdown (controlled by app code) -->
<div id="topSearchMenu" class="dropdown-menu w-100 shadow" style="max-height:60vh; overflow:auto; top: calc(100% + .25rem); left: 0;"> <div id="topSearchMenu" class="dropdown-menu w-100 shadow"
</div> style="max-height:60vh; overflow:auto; top: calc(100% + .25rem); left: 0;">
</div> </div>
</form> </div>
<a class="btn btn-sm btn-outline-secondary" href="https://gitea.sergeych.net/SergeychWorks/lyng" target="_blank" rel="noopener" aria-label="GitHub"> </form>
<i class="bi bi-git"></i> <a class="btn btn-sm btn-outline-secondary" href="https://gitea.sergeych.net/SergeychWorks/lyng"
</a> target="_blank" rel="noopener" aria-label="GitHub">
</div> <i class="bi bi-git"></i>
</a>
</div>
</div> </div>
</div> </div>
</nav> </nav>
<!-- App root; extra top padding so content is not hidden behind fixed navbar --> <!-- App root; extra top padding so content is not hidden behind fixed navbar -->
<div id="root" class="pt-4" tabindex="-1" aria-live="polite" aria-atomic="false"></div> <div id="root" class="pt-4" tabindex="-1" aria-live="polite" aria-atomic="false"></div>
<!-- App bundle (produced by Kotlin/JS). The Gradle config forces this name. --> <!-- App bundle (produced by Kotlin/JS). The Gradle config forces this name. -->
<script src="site.js"></script> <script src="site.js"></script>
<!-- Bootstrap 5.3 JS bundle (includes Popper) --> <!-- Bootstrap 5.3 JS bundle (includes Popper) -->
<script <script
src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
crossorigin="anonymous" crossorigin="anonymous"
></script> ></script>
<script> <script>
// Adjust body padding to account for fixed-top navbar height (handles dynamic font sizes) // Adjust body padding to account for fixed-top navbar height (handles dynamic font sizes)
(function () { (function () {
function adjustPadding() { function adjustPadding() {
var nav = document.querySelector('.navbar.fixed-top'); var nav = document.querySelector('.navbar.fixed-top');
if (!nav) return; if (!nav) return;
var h = nav.getBoundingClientRect().height; var h = nav.getBoundingClientRect().height;
var px = Math.ceil(h) + 'px'; var px = Math.ceil(h) + 'px';
// Keep legacy inline padding for older browsers // Keep legacy inline padding for older browsers
document.body.style.paddingTop = px; document.body.style.paddingTop = px;
// And expose as a CSS variable used by scroll-padding/scroll-margin rules // And expose as a CSS variable used by scroll-padding/scroll-margin rules
// document.documentElement.style.setProperty('--navbar-offset', px); // document.documentElement.style.setProperty('--navbar-offset', px);
} }
window.addEventListener('load', adjustPadding); window.addEventListener('load', adjustPadding);
window.addEventListener('resize', adjustPadding); window.addEventListener('resize', adjustPadding);
// Also listen to Bootstrap collapse events which may change navbar height on small screens // Also listen to Bootstrap collapse events which may change navbar height on small screens
@ -310,30 +465,56 @@
// Basic active state management for topbar links // Basic active state management for topbar links
function updateActive() { function updateActive() {
var hash = location.hash; var hash = location.hash;
// Clear previous actives // Clear previous actives
document.querySelectorAll('#topbarNav .nav-link').forEach(function(a){ document.querySelectorAll('#topbarNav .nav-link').forEach(function (a) {
a.classList.remove('active'); a.classList.remove('active');
a.removeAttribute('aria-current'); a.removeAttribute('aria-current');
}); });
// Mark active for simple routes // Mark active for simple routes
var activeLink = null; var activeLink = null;
if (!hash || hash === '#' || hash === '#/') { if (!hash || hash === '#' || hash === '#/') {
activeLink = document.querySelector('#topbarNav .nav-link[data-route="home"]'); activeLink = document.querySelector('#topbarNav .nav-link[data-route="home"]');
} else if (hash.startsWith('#/docs/')) { } else if (hash.startsWith('#/docs/')) {
// Mark Docs menu root as active // Mark Docs menu root as active
activeLink = document.querySelector('#topbarNav .nav-link.dropdown-toggle'); activeLink = document.querySelector('#topbarNav .nav-link.dropdown-toggle');
} else if (hash.startsWith('#/reference')) { } else if (hash.startsWith('#/reference')) {
activeLink = document.querySelector('#topbarNav .nav-link[data-route="reference"]'); activeLink = document.querySelector('#topbarNav .nav-link[data-route="reference"]');
} }
if (activeLink) { if (activeLink) {
activeLink.classList.add('active'); activeLink.classList.add('active');
activeLink.setAttribute('aria-current', 'page'); activeLink.setAttribute('aria-current', 'page');
} }
} }
window.addEventListener('hashchange', updateActive); window.addEventListener('hashchange', updateActive);
window.addEventListener('load', updateActive); window.addEventListener('load', updateActive);
})(); }
</script>
</body>
</html>
)();
// Set up mutation observer for Kotlin code blocks
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
mutation.addedNodes.forEach((node) => {
if (node.nodeType === Node.ELEMENT_NODE) {
const kotlinBlocks = node.querySelectorAll('code.language-kotlin');
kotlinBlocks.forEach((block) => {
console.log('Found Kotlin code block:', block.textContent);
hljs.highlightElement(block);
});
}
});
});
});
// Start observing document body for changes
observer.observe(document.body, {
childList: true,
subtree: true
});
</script>
</body>
</html>