@@ -116,6 +116,131 @@ The writer produces:
116116- `a2ml-reader.lua` — Standalone reader (189 lines)
117117- `a2ml-writer.lua` — Standalone writer (153 lines)
118118
119+ == Filter: a2ml-filter.lua
120+
121+ `a2ml-filter.lua` is a Pandoc Lua filter that provides post-processing
122+ passes over the AST produced by the A2ML reader. Run it with `--lua-filter`:
123+
124+ [source,sh]
125+ ----
126+ # Full pipeline: read + filter + template
127+ pandoc -f a2ml.lua input.a2ml \
128+ --lua-filter=a2ml-filter.lua \
129+ --template=a2ml.html \
130+ -o output.html
131+ ----
132+
133+ === Capabilities
134+
135+ [cols="1,3"]
136+ |===
137+ | Feature | Description
138+
139+ | Cross-reference resolver
140+ | `@ref(id)` links are validated against actual heading anchors. Resolved refs
141+ get a tooltip; unresolved refs produce a warning and red styling.
142+
143+ | Include directive
144+ | `@include(file.a2ml)` Div elements are replaced with the parsed content of
145+ the referenced file via `pandoc.read()`. Missing files produce a visible
146+ error block rather than silent failure.
147+
148+ | TOC generator
149+ | Auto-generates a Table of Contents from all document headings. Inserted
150+ after the first level-1 heading (or at the top if none exists).
151+
152+ | Diagram rendering
153+ | Code blocks tagged `mermaid` or `graphviz`/`dot` are rendered to inline SVG
154+ via `pandoc.pipe()`. Falls back gracefully to showing source code if the
155+ external tool (mmdc, dot) is not installed.
156+
157+ | SPDX validator
158+ | Checks for `SPDX-License-Identifier` in metadata or early document blocks.
159+ Warns if missing (can be disabled via `a2ml-validate: false` in metadata).
160+
161+ | Metadata enrichment
162+ | Populates `version`, `date`, and `author` from git (`git describe`,
163+ `git log`, `git config`) when not already present in the document.
164+ |===
165+
166+ === Disabling Capabilities
167+
168+ Set metadata flags to disable individual features:
169+
170+ [source,yaml]
171+ ----
172+ ---
173+ a2ml-includes: false
174+ a2ml-diagrams: false
175+ a2ml-validate: false
176+ ---
177+ ----
178+
179+ == HTML Template: a2ml.html
180+
181+ `a2ml.html` is a Pandoc HTML5 template purpose-built for A2ML documents:
182+
183+ [source,sh]
184+ ----
185+ pandoc -f a2ml.lua input.a2ml \
186+ --lua-filter=a2ml-filter.lua \
187+ --template=a2ml.html \
188+ -o output.html
189+ ----
190+
191+ === Template Features
192+
193+ - **SPDX badge** in the document header showing the license identifier
194+ - **Directive styling**: `@abstract` (blue), `@opaque` (amber), `@fig` (green),
195+ `@note` (orange), `@warning` (red) — each with distinct borders, backgrounds,
196+ and auto-generated labels
197+ - **Responsive layout**: fluid max-width container, mobile breakpoints
198+ - **Print-friendly**: clean monochrome output, URLs expanded inline
199+ - **Syntax highlighting**: full Pandoc highlight token coverage
200+ - **TOC styling**: collapsible grey box for the generated table of contents
201+ - **Diagram blocks**: centred SVG container with fallback source display
202+ - **Cross-reference colouring**: resolved refs in blue, unresolved in red
203+
204+ === Template Variables
205+
206+ The template consumes these Pandoc metadata fields:
207+
208+ - `$title$` — document title
209+ - `$author$` — author name
210+ - `$date$` — document date
211+ - `$version$` — document version
212+ - `$spdx-license$` — SPDX license identifier
213+ - `$a2ml-format$` — A2ML format version
214+
215+ == Extensions Table
216+
217+ Both the reader and filter advertise an extensions table:
218+
219+ [cols="1,3"]
220+ |===
221+ | Extension | Purpose
222+
223+ | `+smart`
224+ | Typographic quotes (SmartyPants processing)
225+
226+ | `+includes`
227+ | File inclusion via `@include` directives
228+
229+ | `+diagrams`
230+ | Diagram rendering (mermaid, graphviz/dot)
231+
232+ | `+validate`
233+ | Structural validation (SPDX, cross-references)
234+ |===
235+
236+ == Files
237+
238+ - `a2ml.lua` — Combined reader (360 lines)
239+ - `a2ml-reader.lua` — Standalone reader (189 lines)
240+ - `a2ml-writer.lua` — Standalone writer (153 lines)
241+ - `a2ml-filter.lua` — Lua filter with 6 post-processing passes
242+ - `a2ml.html` — HTML5 template with A2ML-specific CSS
243+
119244== Spec Compliance
120245
121246This reader implements the A2ML v1.0.0 surface syntax as specified in
0 commit comments