Skip to content

Commit 967c22f

Browse files
hyperpolymathclaude
andcommitted
feat(a2ml,k9-svc): add Pandoc custom readers for A2ML and K9 formats
Lua custom readers for pandoc 3.0+ that convert A2ML and K9 files into the Pandoc AST, enabling output to HTML, Markdown, LaTeX, PDF, DOCX, EPUB, and 40+ other formats. a2ml.lua: Headings, @directive(attrs) blocks, inline formatting (**bold**, *italic*, [link](url), @ref(id)), lists, code blocks, and opaque payload preservation. Tested against all 8 test vectors. k9.lua: Auto-detects YAML (.k9) vs Nickel (.k9.ncl) syntax, extracts pedigree metadata, security level (Kennel/Yard/Hunt), contracts, recipes, and multiline strings. Emits semantic CSS classes for styled HTML output. Usage: pandoc -f a2ml.lua input.a2ml -o output.html pandoc -f k9.lua input.k9.ncl -t markdown Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4d2fbff commit 967c22f

4 files changed

Lines changed: 1173 additions & 0 deletions

File tree

a2ml/pandoc/README.adoc

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// SPDX-License-Identifier: PMPL-1.0-or-later
2+
3+
= A2ML Pandoc Custom Reader
4+
:author: Jonathan D.A. Jewell
5+
:revdate: 2026-03-01
6+
7+
== Overview
8+
9+
`a2ml.lua` is a https://pandoc.org/custom-readers.html[Pandoc custom reader]
10+
that converts A2ML (Attested Markup Language) surface syntax into the Pandoc
11+
AST. This enables converting A2ML documents to any format Pandoc supports:
12+
HTML, Markdown, LaTeX, PDF, DOCX, EPUB, and dozens more.
13+
14+
== Usage
15+
16+
[source,sh]
17+
----
18+
# A2ML → HTML
19+
pandoc -f a2ml.lua input.a2ml -o output.html
20+
21+
# A2ML → Markdown
22+
pandoc -f a2ml.lua input.a2ml -t markdown
23+
24+
# A2ML → PDF (via LaTeX)
25+
pandoc -f a2ml.lua input.a2ml -o output.pdf
26+
27+
# A2ML → DOCX
28+
pandoc -f a2ml.lua input.a2ml -o output.docx
29+
30+
# A2ML → JSON AST (for programmatic use)
31+
pandoc -f a2ml.lua input.a2ml -t json
32+
----
33+
34+
== Supported A2ML Features
35+
36+
[cols="1,3"]
37+
|===
38+
| Feature | Pandoc Mapping
39+
40+
| `# Heading` through `##### Heading`
41+
| `Header` (levels 1-5) with auto-generated IDs
42+
43+
| `@directive(attrs): ... @end`
44+
| `Div` with `data-a2ml` attribute and CSS classes
45+
46+
| `@opaque(lang="x"): ... @end`
47+
| `CodeBlock` preserving bytes exactly
48+
49+
| `**bold**`
50+
| `Strong`
51+
52+
| `*italic*`
53+
| `Emph`
54+
55+
| `[label](url)`
56+
| `Link`
57+
58+
| `@ref(id)`
59+
| `Link` targeting `#id` (internal cross-reference)
60+
61+
| `- list items`
62+
| `BulletList`
63+
64+
| `\`\`\`lang ... \`\`\``
65+
| `CodeBlock` with language annotation
66+
67+
| Paragraphs (blank-line separated)
68+
| `Para`
69+
|===
70+
71+
== Directive Handling
72+
73+
A2ML directives are rendered as Pandoc `Div` elements with:
74+
75+
- `id` from the directive's `id` attribute (if present)
76+
- CSS class `a2ml-<name>` (e.g. `a2ml-abstract`, `a2ml-fig`)
77+
- `data-a2ml` HTML attribute matching the directive name
78+
- Additional attributes as `data-*` pairs
79+
80+
The `@opaque` directive is special: its body is rendered as a `CodeBlock`
81+
to preserve byte-exact content, matching the A2ML spec requirement for
82+
deterministic round-tripping.
83+
84+
== Requirements
85+
86+
- Pandoc 3.0+ with Lua support (`+lua` feature)
87+
88+
== Spec Compliance
89+
90+
This reader implements the A2ML v1.0.0 surface syntax as specified in
91+
`SPEC-v1.0.adoc`. Test vectors in `tests/vectors/` validate correct
92+
output for all core constructs.

0 commit comments

Comments
 (0)