(async function () {
"use strict";
const manifest = await fetch("logbook.json", { cache: "no-store" }).then(r => r.json());
const nodes = [manifest.root].concat(manifest.root.children || []);
const nav = document.getElementById("nav");
const content = document.getElementById("content");
function inline(text) {
return text
.replace(/&/g, "&").replace(//g, ">")
.replace(/`([^`]+)`/g, "$1")
.replace(/\*\*([^*]+)\*\*/g, "$1");
}
function markdown(source) {
const lines = source.split("\n");
let html = "", paragraph = [], i = 0;
const flush = () => { if (paragraph.length) { html += `
${inline(paragraph.join(" "))}
`; paragraph = []; } }; while (i < lines.length) { const line = lines[i], t = line.trim(); if (!t) { flush(); i++; continue; } if (t.startsWith("```")) { flush(); const body = []; i++; while (i < lines.length && !lines[i].trim().startsWith("```")) body.push(lines[i++]); html += `${inline(body.join("\n"))}`; i++; continue;
}
const h = t.match(/^(#{1,3})\s+(.*)$/);
if (h) { flush(); html += `${inline(t.slice(2))}`; i++; continue; } if (t.startsWith("- ")) { flush(); const items = []; while (i < lines.length && lines[i].trim().startsWith("- ")) items.push(`
| ${inline(x)} | `).join("")}
|---|
| ${inline(x)} | `).join("")}