repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by bugabinga

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.

13be8d38664ecb11ddd8e57df9d0998bf51c02d0

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

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

Changed files (4)

.pi/autoresearch/session.jsonl

Modified
1 1 {"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"}}
2 2 {"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}}
3 3 {"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}}
4 +{"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"}}

skills/pandoc/SKILL.md

Modified
1134 1134 - `extract-headings.lua` — Extract document outline
1135 1135 - `add-meta-date.lua` — Auto-set date metadata
1136 1136 - `remove-empty-paras.lua` — Strip empty paragraphs
1137 -- `admonitions.lua` — Style `:::note`/`:::warning`/`:::tip` div blocks
1137 +- `admonitions.lua` — Render `:::note`/`:::warning`/`:::tip`/`:::danger` div blocks (styled HTML, portable labels elsewhere)
1138 1138 - `autolink.lua` — Convert bare URLs into clickable links
1139 1139 - `diagram-filter.lua` — Generate Graphviz images from `dot` code blocks via pandoc.pipe + mediabag

skills/pandoc/ideas.md

Modified
5 5 - Typst output (modern LaTeX alternative)
6 6 - Beamer theme reference table
7 7 - Sandbox mode for untrusted input
8 -- Admonitions filter (:::note/:::warning/:::tip/:::danger)
8 +- Admonitions filter (:::note/:::warning/:::tip/:::danger; preserves Markdown formatting, HTML styled + portable fallback)
9 9 - Autolink filter (bare URLs → clickable links)
10 10 - Diagram filter (Graphviz `dot` code blocks via pandoc.pipe + mediabag pattern; graceful fallback if dot missing)
11 11 - pdf-report.yaml and html-report.yaml defaults

skills/pandoc/references/filters/admonitions.lua

Modified
1 --- admonitions.lua — Style :::note, :::warning, :::tip, :::danger div blocks
1 +-- admonitions.lua — Render :::note/warning/tip/danger div blocks
2 2 -- Usage: pandoc --lua-filter=admonitions.lua doc.md -o out.html
4 --- In your Markdown:
4 +-- In Markdown:
5 5 -- ::: note
6 --- This is a note.
6 +-- This is a **note** with full Markdown support.
7 7 -- :::
9 --- ::: warning
10 --- Be careful!
11 --- :::
9 +-- HTML output gets inline styling. Other formats get a portable label
10 +-- paragraph followed by the original block content.
13 12 local types = {
14 - note = { icon = "ℹ", color = "#d1ecf1", border = "#0c5460" },
15 - tip = { icon = "💡", color = "#d4edda", border = "#155724" },
16 - warning = { icon = "⚠", color = "#fff3cd", border = "#856404" },
17 - danger = { icon = "✕", color = "#f8d7da", border = "#721c24" },
13 + note = { icon = "ℹ", label = "NOTE", color = "#d1ecf1", border = "#0c5460" },
14 + tip = { icon = "💡", label = "TIP", color = "#d4edda", border = "#155724" },
15 + warning = { icon = "⚠", label = "WARNING", color = "#fff3cd", border = "#856404" },
16 + danger = { icon = "✕", label = "DANGER", color = "#f8d7da", border = "#721c24" },
20 -local function html_admonition(el, adm_type)
21 - local conf = types[adm_type]
22 - if not conf then return el end
23 - local content_html = pandoc.utils.stringify(el.content)
24 - -- Wrap in raw HTML block for HTML output
25 - if FORMAT:match 'html' then
26 - local html = string.format(
27 - '<div style="padding:0.75em 1em;margin:1em 0;border-left:4px solid %s;' ..
28 - 'background:%s;border-radius:4px;"><strong>%s</strong> %s</div>',
29 - conf.border, conf.color, conf.icon .. " " .. adm_type:upper(), content_html
30 - )
31 - return pandoc.RawBlock('html', html)
32 - elseif FORMAT:match 'latex' then
33 - return {
34 - pandoc.RawBlock('latex', '\\begin{tcolorbox}[colback=' .. conf.color ..
35 - ',colframe=' .. conf.border .. ',title={' .. conf.icon .. ' ' ..
36 - adm_type:upper() .. '}]'),
37 - el.content,
38 - pandoc.RawBlock('latex', '\\end{tcolorbox}'),
39 - }
19 +local function portable_blocks(el, conf)
20 + local blocks = {
21 + pandoc.Para({pandoc.Strong({pandoc.Str("[" .. conf.label .. "]")})})
22 + }
23 + for _, block in ipairs(el.content) do
24 + blocks[#blocks + 1] = block
41 - return el
26 + return blocks
27 +end
29 +local function html_admonition(el, conf)
30 + -- Preserve full Markdown formatting by writing inner blocks to HTML.
31 + local content_html = pandoc.write(pandoc.Pandoc(el.content), "html")
32 + local title = conf.icon .. " " .. conf.label
33 + local html = string.format(
34 + '<div class="admonition %s" style="padding:0.75em 1em;margin:1em 0;' ..
35 + 'border-left:4px solid %s;background:%s;border-radius:4px;">\n' ..
36 + '<p><strong>%s</strong></p>\n%s\n</div>',
37 + conf.label:lower(), conf.border, conf.color, title, content_html
38 + )
39 + return pandoc.RawBlock("html", html)
44 42 function Div(el)
45 43 local adm_type = el.classes[1]
46 - if types[adm_type] then
47 - return html_admonition(el, adm_type)
44 + local conf = types[adm_type]
45 + if not conf then return el end
47 + if FORMAT:match("html") then
48 + return html_admonition(el, conf)
49 - return el
51 + return portable_blocks(el, conf)