LordOS — a free, fast and secure GNU/Linux distribution based on Debian, with its own desktop environment: display server and Wayland compositor in C, a React UI engine on QuickJS, and private native apps.
C cdebiandesktop-environmentebpffirewalllandlocklinuxlinux-distributionopen-sourceprivacyquickjsraspberry-pi-5reactsecuritywaylandwayland-compositor
// papermd.mjs — docs/PAPER.md, the paper's English copy on GitHub, generated from web/content/paper/paper.en.md
// on every site build so the two never drift apart (it stayed at 0.8.0 for five releases once). Diagrams
// ([[diagram:id]]) become text figures from diagrams.json; screenshots become their caption.
const L = (v) => (v && typeof v === 'object' ? v.en : v) || '';
function figure(d) {
const out = [`**Figure: ${L(d.title)}.**`, '', '```'];
if (d.kind === 'flow') {
const label = (from, to) => (d.edges || []).find((e) => e.from === from && e.to === to);
d.nodes.forEach((n, i) => {
out.push(`[${L(n.label)}] ${L(n.sub)}`);
const next = d.nodes[i + 1];
if (next) { const e = label(n.id, next.id); out.push(` │${e && L(e.label) ? ' ' + L(e.label) : ''}`, ' ▼'); }
});
} else {
d.nodes.forEach((n, i) => {
out.push(L(n.label), ` ${L(n.sub)}`);
if (i < d.nodes.length - 1) out.push(' │');
});
}
out.push('```');
if (L(d.caption)) out.push('', `*${L(d.caption)}*`);
return out.join('\n');
}
export function paperMarkdown(body, meta, diagrams) {
const byId = Object.fromEntries((diagrams || []).map((d) => [d.id, d]));
const text = body
.replace(/^\[\[diagram:([\w-]+)\]\]$/gm, (m, id) => (byId[id] ? figure(byId[id]) : ''))
.replace(/^\[\[screenshot:[^\]]*\]\]$/gm, '')
.replace(/\n{3,}/g, '\n\n')
.trim();
const authors = (meta.authors || []).join(', ');
return [
`# ${L(meta.title)}`,
'',
`*${L(meta.subtitle)}*`,
'',
`Version ${meta.version} · ${meta.date}${authors ? ` · ${authors}` : ''}${meta.org ? ` (${L(meta.org)})` : ''}`,
'',
'> This is the English copy of the paper published on lordos.org (https://lordos.org/paper/), where the',
'> figures are drawn as diagrams. It is generated by the site build from `web/content/paper/paper.en.md`',
'> and `web/content/paper/diagrams.json`: edit those, not this file.',
'',
text,
'',
].join('\n');
}