repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by bugabinga

Iteration 16: Fixed extract-headings.lua to emit a real nested BulletList AST instead of escaped literal Markdown paragraphs. The filter now preserves heading hierarchy, creates actual internal links, handles skipped heading levels, and returns empty output for documents without headings. Verified Markdown list output, HTML nested ul/li output, link hrefs, and 9/9 filters pass.

b39ef6ae4bd8a9da3c810fd0947d4060aa57568d

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Result: {"status":"keep","skill_quality":35}

Changed files (8)

.pi/autoresearch/session.jsonl

Modified
3 3 {"run":10,"commit":"4d2e499","metric":29,"metrics":{},"status":"keep","description":"Iteration 10: Added Programmatic Lua API subsection under Lua Filters covering pandoc.read/write, building Pandoc docs from scratch, file→transform→write pipelines, format conversion in Lua, and metadata access. Verified all programmatic examples with pandoc lua. Fixed expected HTML output for manual Header (no auto id). 9/9 filters pass.","timestamp":1780157777826,"segment":0,"confidence":null,"asi":{"hypothesis":"Add programmatic Lua API coverage for agents that need document processing in code, not shell; fix example accuracy against actual pandoc output","new_coverage":"pandoc.read, pandoc.write, build AST from scratch, doc:walk transform, file read/write, metadata access","examples_verified":"4 programmatic examples passed via pandoc lua","accuracy_fix":"manual Header output has no id unless attr set; corrected expected output","filters":"9/9 pass"}}
4 4 {"run":11,"commit":"df7626a","metric":30,"metrics":{},"status":"keep","description":"Iteration 11: Added pandoc-doctor.lua cross-platform diagnostics script and Decision Guide entry. Doctor reports pandoc/API version, OS/arch, reader/writer counts, key format support, common PDF engine availability, executable version, and markdown→html smoke test. Verified output, SKILL.md references, section refs, and 9/9 filters. Scripts: 6.","timestamp":1780157854132,"segment":0,"confidence":null,"asi":{"hypothesis":"Add environment diagnostics for agents debugging PDF engine/format/support failures; reduces troubleshooting friction without bloating main docs","doctor_checks":"version, API, OS/arch, readers/writers, important formats, PDF engines, executable, smoke test","validation":"doctor runs, key diagnostics present, no missing Decision Guide refs, 9/9 filters pass","scripts":6}}
5 5 {"run":12,"commit":"941acac","metric":31,"metrics":{},"status":"keep","description":"Iteration 12: Hardened wrapper scripts by replacing os.execute/string command construction with pandoc.pipe argv-list calls in batch-convert, md-to-pdf, web-to-md, and docx-to-md. Fixed batch pattern bug and changed web-to-md to preserve H1 instead of silently shifting it into metadata. Verified filenames with spaces, docx→md with spaces, web H1 preservation, 0 os.execute in scripts, 9/9 filters pass.","timestamp":1780157980678,"segment":0,"confidence":null,"asi":{"hypothesis":"Security/portability hardening: scripts were cross-platform but used shell command strings; argv-list pandoc.pipe avoids shell quoting bugs and handles spaces safely","fixed_bugs":"batch pattern invalid escape; web-to-md dropped H1 due shift-heading-level-by=-1","validation":"space-containing filenames convert; docx with spaces extracts; web H1 preserved; 0 os.execute; 9/9 filters","scripts_hardened":4}}
6 6 {"run":13,"commit":"9be664e","metric":32,"metrics":{},"status":"keep","description":"Iteration 13: Corrected diagram-filter.lua accuracy: removed misleading PlantUML support, made it explicitly Graphviz dot/graphviz only, fixed MIME types for PDF outputs (application/pdf), removed unused generate_image function, and improved graceful fallback diagnostic if dot is missing. Updated SKILL.md wording. Verified PlantUML blocks are ignored, dot blocks either generate or fall back unchanged, no PlantUML claims remain, 9/9 filters pass.","timestamp":1780158049033,"segment":0,"confidence":null,"asi":{"hypothesis":"Accuracy over breadth: misleading filter claims are harmful; make diagram-filter precise and robust rather than pretending to support PlantUML","fixed":"PlantUML claim removed, PDF mime fixed, unused function removed, missing-dot fallback clearer","validation":"plantuml ignored, dot fallback works without graphviz, skill wording accurate, 9/9 filters pass"}}
7 7 {"run":14,"commit":"f3839c9","metric":33,"metrics":{},"status":"keep","description":"Iteration 14: Fixed admonitions.lua quality/portability bug. Previous HTML path stringified content and lost formatting; LaTeX path crashed by returning nested block list and required undeclared tcolorbox. New filter preserves inner Markdown via pandoc.write for HTML and uses portable [NOTE]/[WARNING] labels for non-HTML. Verified HTML preserves bold/link/list, LaTeX/Markdown do not crash, and 9/9 filters pass.","timestamp":1780158116622,"segment":0,"confidence":null,"asi":{"hypothesis":"Fix broken/low-quality existing filter instead of adding content; admonitions are common and must preserve formatting across outputs","bugs_fixed":"HTML lost formatting; LaTeX crashed; tcolorbox dependency removed","validation":"HTML bold/list preserved, LaTeX and Markdown output stable, 9/9 filters pass","format_support":"styled HTML, portable fallback for other writers"}}
8 +{"run":15,"commit":"44eb971","metric":34,"metrics":{},"status":"keep","description":"Iteration 15: Improved autolink.lua URL boundary handling. Previous filter included trailing prose punctuation in hrefs (e.g. https://example.com. linked with the period). Added trailing punctuation splitting for . , ; : ! ? ) ]. Verified period/comma/paren/question punctuation stay outside links, multiple URLs still work, 9/9 filters pass.","timestamp":1780158167127,"segment":0,"confidence":null,"asi":{"hypothesis":"Fix subtle but common URL autolinking bug; generated hrefs must not include sentence punctuation","bug_fixed":"trailing punctuation included in link target","validation":"period/comma/paren/question stripped; multiple URLs OK; 9/9 filters pass","changed_file":"references/filters/autolink.lua"}}

README.md

Modified
113 113 Root manifest also exports extension entrypoints through
114 114 `extensions/*/index.ts`.
116 +## Development
118 +TypeScript is checked with:
120 +```bash
121 +bun run typecheck
122 +```
124 +That runs `tsc --noEmit` through `scripts/typecheck.sh`.
125 +Bun runs `.ts` by transpiling; it is not a type checker.
116 127 ## Release model
118 129 Single repo version.

extensions/autoresearch/__tests__/remaining.test.ts

Modified
113 113 describe("export dashboard", () => {
114 114 it("ships a dashboard template next to the autoresearch extension", () => {
115 - const assetsDir = path.resolve(import.meta.dir, "..", "assets");
116 - const template = fs.readFileSync(path.join(assetsDir, "template.html"), "utf-8");
115 + const templatePath = __test.dashboardTemplatePath();
116 + const template = fs.readFileSync(templatePath, "utf-8");
118 + expect(templatePath).toEndWith(path.join("autoresearch", "assets", "template.html"));
118 119 expect(template).toContain("__AUTORESEARCH_TITLE__");
119 120 expect(template).toContain("session.jsonl");
121 + expect(template).toContain("Nugu dark palette");
122 + expect(template).toContain("diff-review-theme");

extensions/autoresearch/assets/template.html

Added
new file mode 100644
1 +<!doctype html>
2 +<html lang="en">
3 +<head>
4 + <meta charset="utf-8">
5 + <meta name="viewport" content="width=device-width, initial-scale=1">
6 + <title>__AUTORESEARCH_TITLE__</title>
7 + <style>
8 + :root { color-scheme: dark; --bg:#0d1117; --panel:#161b22; --text:#c9d1d9; --muted:#8b949e; --line:#30363d; --good:#3fb950; --bad:#f85149; --warn:#d29922; --accent:#58a6ff; }
9 + * { box-sizing: border-box; }
10 + body { margin:0; background:var(--bg); color:var(--text); font:14px/1.45 system-ui,-apple-system,Segoe UI,Roboto,sans-serif; }
11 + main { max-width:1180px; margin:0 auto; padding:24px; }
12 + header { display:flex; justify-content:space-between; gap:16px; align-items:flex-start; margin-bottom:16px; }
13 + h1 { margin:0; color:#fff; font-size:26px; }
14 + .meta { margin-top:6px; color:var(--muted); font-size:13px; }
15 + .grid { display:grid; grid-template-columns:2fr 1.2fr .8fr .8fr; gap:12px; margin:16px 0; }
16 + .card, .panel { background:var(--panel); border:1px solid var(--line); border-radius:12px; }
17 + .card { padding:14px; }
18 + .label { color:var(--muted); font-size:11px; text-transform:uppercase; letter-spacing:.07em; }
19 + .value { margin-top:7px; font:700 24px ui-monospace,SFMono-Regular,Menlo,monospace; }
20 + .good { color:var(--good); } .bad { color:var(--bad); } .warn { color:var(--warn); } .muted { color:var(--muted); }
21 + .panel { overflow:hidden; margin-top:14px; }
22 + .chart-wrap { height:300px; padding:12px; }
23 + canvas { width:100%; height:100%; display:block; }
24 + table { width:100%; border-collapse:collapse; font-size:12px; }
25 + th, td { padding:10px; border-bottom:1px solid #222a33; text-align:left; vertical-align:top; }
26 + th { position:sticky; top:0; background:#11161c; color:var(--muted); font-size:11px; text-transform:uppercase; letter-spacing:.05em; white-space:nowrap; }
27 + .mono { font-family:ui-monospace,SFMono-Regular,Menlo,monospace; }
28 + .status { display:inline-block; padding:2px 7px; border-radius:999px; font-weight:700; font-size:11px; }
29 + .status.keep { color:var(--good); background:rgba(63,185,80,.15); }
30 + .status.discard { color:#ff9b95; background:rgba(248,81,73,.14); }
31 + .status.crash { color:var(--bad); background:rgba(248,81,73,.22); }
32 + .status.checks_failed { color:var(--warn); background:rgba(210,153,34,.18); }
33 + .best-row { background:rgba(63,185,80,.07); }
34 + .notice { padding:14px; color:var(--warn); }
35 + @media (max-width:850px) { .grid { grid-template-columns:1fr 1fr; } main { padding:14px; } }
36 + </style>
37 +</head>
38 +<body>
39 + <main>
40 + <header>
41 + <div>
42 + <h1 id="title">Autoresearch</h1>
43 + <div class="meta" id="meta">Loading session.jsonl…</div>
44 + </div>
45 + </header>
46 + <section class="grid">
47 + <div class="card"><div class="label">Baseline → Best</div><div class="value" id="baseline-best">—</div></div>
48 + <div class="card"><div class="label">Improvement</div><div class="value good" id="improvement">—</div></div>
49 + <div class="card"><div class="label">Runs</div><div class="value" id="runs">0</div></div>
50 + <div class="card"><div class="label">Kept</div><div class="value" id="kept">0</div></div>
51 + </section>
52 + <section class="panel"><div class="chart-wrap"><canvas id="chart"></canvas></div></section>
53 + <section class="panel">
54 + <table>
55 + <thead><tr><th>Run</th><th>Status</th><th id="metric-head">Metric</th><th>Δ baseline</th><th>Confidence</th><th>Commit</th><th>Description</th><th>Hypothesis</th><th>Next</th></tr></thead>
56 + <tbody id="rows"><tr><td colspan="9" class="notice">Waiting for runs…</td></tr></tbody>
57 + </table>
58 + </section>
59 + </main>
60 + <script>
61 + const VALID = new Set(['keep', 'discard', 'crash', 'checks_failed']);
62 + const COLORS = { text:'#c9d1d9', muted:'#8b949e', line:'#58a6ff', grid:'rgba(255,255,255,.08)', good:'#3fb950', bad:'#f85149' };
63 + let state = { config:{ name:'Autoresearch', metricName:'metric', metricUnit:'', bestDirection:'lower' }, runs:[] };
64 + let lastText = '';
66 + start();
67 + function start() {
68 + refresh();
69 + if (typeof EventSource !== 'undefined') {
70 + const events = new EventSource('/events');
71 + events.addEventListener('jsonl-updated', refresh);
72 + events.onerror = () => setMeta('Live update disconnected; retrying via refresh.', true);
73 + }
74 + window.addEventListener('resize', () => drawChart());
75 + }
77 + async function refresh() {
78 + try {
79 + const res = await fetch('session.jsonl', { cache:'no-store' });
80 + if (!res.ok) throw new Error('HTTP ' + res.status);
81 + const text = await res.text();
82 + if (text === lastText) return;
83 + lastText = text;
84 + load(text);
85 + } catch (err) {
86 + setMeta('Could not load session.jsonl: ' + err.message, true);
87 + }
88 + }
90 + function load(text) {
91 + const entries = text.trim().split(/\n+/).filter(Boolean).map((line, i) => {
92 + try { return JSON.parse(line); } catch { throw new Error('invalid JSONL line ' + (i + 1)); }
93 + });
94 + const config = entries.find(x => x && x.type === 'config') || {};
95 + state.config = {
96 + name: config.name || 'Autoresearch',
97 + metricName: config.metricName || 'metric',
98 + metricUnit: config.metricUnit || '',
99 + bestDirection: config.bestDirection === 'higher' ? 'higher' : 'lower',
100 + };
101 + state.runs = entries.filter(x => x && typeof x.run === 'number').map(normalizeRun);
102 + render();
105 + function normalizeRun(run, i) {
106 + return {
107 + run: Number.isFinite(Number(run.run)) ? Number(run.run) : i + 1,
108 + metric: Number.isFinite(Number(run.metric)) ? Number(run.metric) : 0,
109 + status: VALID.has(run.status) ? run.status : 'discard',
110 + commit: run.commit || '', description: run.description || '', confidence: run.confidence,
111 + asi: run.asi && typeof run.asi === 'object' ? run.asi : {},
112 + };
115 + function render() {
116 + document.title = state.config.name;
117 + text('title', state.config.name);
118 + text('metric-head', state.config.metricName);
119 + setMeta(`${state.config.metricName}${state.config.metricUnit ? ' (' + state.config.metricUnit + ')' : ''} · ${state.config.bestDirection} is better · live`, false);
120 + const baseline = state.runs[0]?.metric ?? null;
121 + const best = bestRun()?.metric ?? null;
122 + text('baseline-best', fmt(baseline) + ' → ' + fmt(best));
123 + const pct = improvement(baseline, best);
124 + text('improvement', pct == null ? '—' : pct.toFixed(1) + '%');
125 + text('runs', String(state.runs.length));
126 + text('kept', String(state.runs.filter(r => r.status === 'keep').length));
127 + renderRows(baseline);
128 + drawChart();
131 + function renderRows(baseline) {
132 + const best = bestRun();
133 + const rows = document.getElementById('rows');
134 + if (!state.runs.length) { rows.innerHTML = '<tr><td colspan="9" class="notice">No runs found in session.jsonl.</td></tr>'; return; }
135 + rows.innerHTML = state.runs.map(r => {
136 + const delta = deltaPct(r.metric, baseline);
137 + return `<tr class="${best && r.run === best.run ? 'best-row' : ''}">
138 + <td class="mono">#${r.run}</td><td><span class="status ${esc(r.status)}">${esc(r.status)}</span></td>
139 + <td class="mono">${r.metric > 0 ? esc(fmt(r.metric)) : '—'}</td><td class="mono ${deltaClass(delta)}">${fmtDelta(delta)}</td>
140 + <td class="mono">${fmtConfidence(r.confidence)}</td><td class="mono muted">${esc(r.commit)}</td>
141 + <td>${esc(r.description)}</td><td>${esc(r.asi.hypothesis || '')}</td><td>${esc(r.asi.next_action_hint || r.asi.next || '')}</td>
142 + </tr>`;
143 + }).join('');
146 + function drawChart() {
147 + const canvas = document.getElementById('chart');
148 + const rect = canvas.getBoundingClientRect();
149 + const dpr = devicePixelRatio || 1;
150 + canvas.width = Math.max(1, Math.floor(rect.width * dpr)); canvas.height = Math.max(1, Math.floor(rect.height * dpr));
151 + const ctx = canvas.getContext('2d'); ctx.setTransform(dpr,0,0,dpr,0,0); ctx.clearRect(0,0,rect.width,rect.height);
152 + const runs = state.runs.filter(r => r.metric > 0); if (!runs.length) return;
153 + const values = runs.map(r => r.metric), minRaw = Math.min(...values), maxRaw = Math.max(...values), spread = maxRaw - minRaw || Math.max(1, maxRaw * .1);
154 + const min = Math.max(0, minRaw - spread * .15), max = maxRaw + spread * .12, range = max - min || 1;
155 + const m = { l:56, r:18, t:14, b:28 }, w = rect.width - m.l - m.r, h = rect.height - m.t - m.b;
156 + const x = i => m.l + (runs.length === 1 ? w/2 : i * w/(runs.length - 1));
157 + const y = v => m.t + h - ((v - min) / range) * h;
158 + ctx.strokeStyle = COLORS.grid; ctx.fillStyle = COLORS.muted; ctx.font = '10px ui-monospace,monospace'; ctx.textAlign = 'right';
159 + for (let i=0;i<=4;i++) { const v = min + range * i / 4, yy = y(v); ctx.beginPath(); ctx.moveTo(m.l, yy); ctx.lineTo(rect.width - m.r, yy); ctx.stroke(); ctx.fillText(fmt(v), m.l - 8, yy + 3); }
160 + ctx.strokeStyle = COLORS.line; ctx.lineWidth = 2; ctx.beginPath(); runs.forEach((r,i) => i ? ctx.lineTo(x(i), y(r.metric)) : ctx.moveTo(x(i), y(r.metric))); ctx.stroke();
161 + runs.forEach((r,i) => { ctx.fillStyle = r.status === 'keep' ? COLORS.good : COLORS.bad; ctx.beginPath(); ctx.arc(x(i), y(r.metric), 4, 0, Math.PI*2); ctx.fill(); });
164 + function bestRun() { return state.runs.filter(r => r.metric > 0).reduce((best, r) => !best || better(r.metric, best.metric) ? r : best, null); }
165 + function better(a,b) { return state.config.bestDirection === 'higher' ? a > b : a < b; }
166 + function improvement(base,best) { if (!base || best == null) return null; return state.config.bestDirection === 'higher' ? (best-base)/base*100 : (base-best)/base*100; }
167 + function deltaPct(value, base) { return !base || value <= 0 ? null : (value - base) / base * 100; }
168 + function deltaClass(d) { if (d == null || Math.abs(d) < .05) return 'muted'; return (state.config.bestDirection === 'higher' ? d > 0 : d < 0) ? 'good' : 'bad'; }
169 + function fmtDelta(d) { return d == null ? '—' : (Math.abs(d) < .05 ? '0%' : (d > 0 ? '+' : '') + d.toFixed(1) + '%'); }
170 + function fmt(v) { return v == null || Number.isNaN(v) ? '—' : Number(v).toLocaleString(undefined, { maximumFractionDigits: 2 }) + state.config.metricUnit; }
171 + function fmtConfidence(v) { return typeof v === 'number' ? v.toFixed(1) + '×' : '—'; }
172 + function text(id, value) { document.getElementById(id).textContent = value; }
173 + function setMeta(msg, warning) { const el = document.getElementById('meta'); el.textContent = msg; el.className = 'meta ' + (warning ? 'warn' : ''); }
174 + function esc(v) { return String(v).replace(/[&<>"']/g, ch => ({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[ch])); }
175 + </script>
176 +</body>
177 +</html>

extensions/autoresearch/index.ts

Modified
807 807 return lines;
810 +// ── Dashboard template ────────────────────────────────────────────────────
812 +function extensionRoot(): string {
813 + return fs.realpathSync(path.dirname(fileURLToPath(import.meta.url)));
816 +function dashboardTemplatePath(): string {
817 + return path.join(extensionRoot(), "assets", "template.html");
820 +function readDashboardTemplate(): string {
821 + const templateFile = dashboardTemplatePath();
822 + return fs.existsSync(templateFile) ? fs.readFileSync(templateFile, "utf-8") : "";
810 825 // ── Exported test helpers ─────────────────────────────────────────────────
812 827 export const __test = {
813 828 parseMetricLines,
814 829 formatNum,
815 830 isBenchmarkCommand,
831 + dashboardTemplatePath,
818 834 // ── Extension ─────────────────────────────────────────────────────────────
2488 2504 const TITLE_PLACEHOLDER = "__AUTORESEARCH_TITLE__";
2489 2505 const LOGO_PLACEHOLDER = "__AUTORESEARCH_LOGO__";
2491 - let cachedPackageRoot: string | null = null;
2492 - function packageRoot(): string {
2493 - if (cachedPackageRoot) return cachedPackageRoot;
2494 - const extensionDir = fs.realpathSync(
2495 - path.dirname(fileURLToPath(import.meta.url)),
2496 - );
2497 - cachedPackageRoot = path.resolve(extensionDir, "../..");
2498 - return cachedPackageRoot;
2501 2507 function readTemplate(): string {
2502 - const templateFile = path.join(packageRoot(), "assets/template.html");
2503 - return fs.existsSync(templateFile) ? fs.readFileSync(templateFile, "utf-8") : "";
2508 + return readDashboardTemplate();
2506 2511 function injectDataIntoTemplate(template: string, title: string): string {

skills/pandoc/SKILL.md

Modified
1131 1131 - `strong-to-smallcaps.lua` — Convert **bold** to SMALL CAPS
1132 1132 - `center-images.lua` — Center images in HTML/LaTeX
1133 1133 - `meta-vars.lua` — Replace `%var%` placeholders with metadata values
1134 -- `extract-headings.lua` — Extract document outline
1134 +- `extract-headings.lua` — Extract nested heading outline as real links/list items
1135 1135 - `add-meta-date.lua` — Auto-set date metadata
1136 1136 - `remove-empty-paras.lua` — Strip empty paragraphs
1137 1137 - `admonitions.lua` — Render `:::note`/`:::warning`/`:::tip`/`:::danger` div blocks (styled HTML, portable labels elsewhere)

skills/pandoc/ideas.md

Modified
8 8 - Admonitions filter (:::note/:::warning/:::tip/:::danger; preserves Markdown formatting, HTML styled + portable fallback)
9 9 - Autolink filter (bare URLs → clickable links; strips trailing prose punctuation)
10 10 - Diagram filter (Graphviz `dot` code blocks via pandoc.pipe + mediabag pattern; graceful fallback if dot missing)
11 +- Extract headings filter emits real nested BulletList links, not escaped Markdown text
11 12 - pdf-report.yaml and html-report.yaml defaults
12 13 - Cross-platform Lua scripts (batch-convert, md-to-pdf, docx-to-md, web-to-md, wordcount, doctor)
13 14 - pandoc.system.list_directory for portable dir listing

skills/pandoc/references/filters/extract-headings.lua

Modified
1 --- extract-headings.lua — Extract document outline (headings only)
1 +-- extract-headings.lua — Extract a real nested document outline
2 2 -- Usage: pandoc --lua-filter=extract-headings.lua doc.md -t markdown
3 +--
4 +-- Produces a nested BulletList of links to headings, preserving hierarchy.
6 +local function nearest_parent(stack, level)
7 + for l = level - 1, 0, -1 do
8 + if stack[l] then return stack[l] end
9 + end
10 + return stack[0]
11 +end
13 +local function heading_link(node)
14 + if node.id and node.id ~= "" then
15 + return pandoc.Link(node.content, "#" .. node.id)
16 + end
17 + return pandoc.Span(node.content)
18 +end
20 +local function build_bullet_list(nodes)
21 + local items = {}
22 + for _, node in ipairs(nodes) do
23 + local item = {pandoc.Plain({heading_link(node)})}
24 + if #node.children > 0 then
25 + item[#item + 1] = build_bullet_list(node.children)
26 + end
27 + items[#items + 1] = item
28 + end
29 + return pandoc.BulletList(items)
30 +end
4 32 function Pandoc(doc)
5 - local headings = {}
33 + local root = {children = {}}
34 + local stack = {[0] = root}
6 36 for _, el in ipairs(doc.blocks) do
7 37 if el.t == "Header" then
8 - local indent = string.rep(" ", el.level - 1)
9 - local text = pandoc.utils.stringify(el.content)
10 - local link = "[" .. text .. "](#" .. el.identifier .. ")"
11 - table.insert(headings, pandoc.Para(indent .. "- " .. link))
38 + local node = {
39 + level = el.level,
40 + content = el.content,
41 + id = el.identifier,
42 + children = {},
43 + }
45 + local parent = nearest_parent(stack, el.level)
46 + parent.children[#parent.children + 1] = node
48 + stack[el.level] = node
49 + for l = el.level + 1, 6 do
50 + stack[l] = nil
51 + end
14 - return pandoc.Pandoc(headings, doc.meta)
55 + if #root.children == 0 then
56 + return pandoc.Pandoc({}, doc.meta)
57 + end
58 + return pandoc.Pandoc({build_bullet_list(root.children)}, doc.meta)