Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
c0129d5
feat(parser): add registered block macro sessions and target queries
nlopes Nov 11, 2026
402a49f
feat(parser): add ordered tree processors and checked document edits
nlopes Nov 11, 2026
ae70f47
refactor(parser): make preprocessing resumable across includes
nlopes Nov 12, 2026
4ef9d65
refactor(parser): drive accepted document blocks outside PEG
nlopes Nov 12, 2026
f631b89
refactor(parser): construct committed containers outside PEG
nlopes Nov 12, 2026
b8ec58d
refactor(parser): coordinate source reading with committed construction
nlopes Nov 12, 2026
1dcc245
perf(parser): preserve fast paths in committed source construction
nlopes Nov 12, 2026
92b35cd
perf(parser): move owned include context into cursors
nlopes Nov 13, 2026
0362bcc
perf(parser): reuse unchanged selected include buffers
nlopes Nov 13, 2026
86596f7
perf(parser): write accepted block results into coordinator storage
nlopes Nov 13, 2026
80a28e0
refactor(parser): stream committed compound and table content
nlopes Nov 14, 2026
0a00170
feat(parser): run registered macros in source order
nlopes Nov 14, 2026
3f5c51a
feat(parser): retain title source context for extension queries
nlopes Nov 14, 2026
ac80f91
test(parser): verify semantic query and target identity contracts
nlopes Nov 14, 2026
1b3150e
feat(parser): construct and replace extension blocks atomically
nlopes Nov 14, 2026
38b7855
test(parser): cover construction with public diagram consumers
nlopes Nov 14, 2026
8735389
feat(extensions): capture and resolve deferred display content
nlopes Nov 15, 2026
2bc2bab
feat(converters): render captured titles and finalized captions
nlopes Nov 15, 2026
5257a8c
feat(converters): expose a shared extension pipeline
nlopes Nov 15, 2026
4b0ee7f
feat(cli): use the shared extension pipeline for conversion
nlopes Nov 15, 2026
cf83169
feat(converters): register native block renderer sessions
nlopes Nov 16, 2026
27fd755
feat(html): host native block renderer sessions
nlopes Nov 16, 2026
3c90f68
feat(extensions): compose generated content with typed inline inputs
nlopes Nov 16, 2026
4a3c2d9
feat(extensions): retain macro calls for located literal recovery
nlopes Nov 16, 2026
866c56a
fix(converters): honor scoped attributes in native block renderers
nlopes Nov 18, 2026
d519e7c
perf(parser): streamline block metadata and author name parsing
nlopes Nov 18, 2026
092fa61
perf(parser): avoid copying the document for each checked edit
nlopes Nov 18, 2026
55588c0
fix(extensions): bind deferred requests to their owning macro
nlopes Nov 18, 2026
070bf8e
perf(parser): speed up tag selection on complete include lines
nlopes Nov 19, 2026
2d26378
feat(parser): add entry-source preprocessors with mapped line edits
nlopes Nov 19, 2026
8fa7ff4
feat(parser): add document-local include processors
nlopes Nov 19, 2026
f5ee9f1
feat(parser): let block macros return ordinary blocks
nlopes Nov 19, 2026
6f32f9d
feat(parser): register raw styles for listing and literal blocks
nlopes Nov 19, 2026
e3a2be1
feat(parser): parse child blocks requested by registered styles
nlopes Nov 20, 2026
c24e569
test(parser): cover tree edits to compound style children
nlopes Nov 20, 2026
b4ad382
fix(parser): keep ordinary parsing unchanged with extensions active
nlopes Nov 21, 2026
84061d6
fix(parser): fail instead of discarding content after a block macro ran
nlopes Nov 21, 2026
5061e4a
fix(parser): keep anchors and footnotes out of generated display links
nlopes Nov 21, 2026
8f37c6a
feat(parser): let block styles report located warnings
nlopes Nov 21, 2026
eb18b70
fix(parser): preserve authored alt text for images returned by block …
nlopes Nov 21, 2026
a1c568b
feat(parser): let block macros read local targets under the include p…
nlopes Nov 21, 2026
c21a157
feat(parser): preserve quoted macro arguments forwarded to generated …
nlopes Nov 21, 2026
ff502de
feat(parser): normalize registered cross-reference targets before res…
nlopes Nov 21, 2026
cd60df3
feat(extensions): expand registered inline macros per conversion
nlopes Nov 21, 2026
da2e53e
feat(converters): delegate accepted blocks through the HTML renderer …
nlopes Nov 22, 2026
b11788a
feat(html): run ordered docinfo hooks at document insertion points
nlopes Nov 22, 2026
121daa9
feat(converters): postprocess completed text before delivery
nlopes Nov 22, 2026
b16ab8b
feat(converters): register backend names and typed variants before pa…
nlopes Nov 22, 2026
07111f0
feat(cli): select statically registered converters for every conversi…
nlopes Nov 22, 2026
eb78958
fix(parser): honor enclosing section boundaries in streamed quotes
nlopes Nov 22, 2026
419212a
fix(parser): recover failed children in streamed compounds
nlopes Nov 22, 2026
46112ec
fix(parser): recognize adjacent table delimiters in list attachments
nlopes Nov 22, 2026
c6016f9
fix(parser): stop streamed tables at the enclosing compound delimiter
nlopes Nov 22, 2026
6c80f1f
docs: describe the extension lifecycle and converter registration
nlopes Nov 22, 2026
1a814cb
feat(converters): target output hooks by backend family or variant
nlopes Nov 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 89 additions & 18 deletions ARCHITECTURE.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,83 @@ The preprocessed text gets transformed into an Abstract Syntax Tree (AST).
The primary PEG grammar lives in `grammar/document/peg.rs` using the `peg::parser!` macro.
It handles document structure (header, sections, blocks), block-level elements (paragraphs, lists, tables, delimited blocks), attributes and metadata, and all the nesting rules.

==== Registered extensions

The parser owns an optional extension registry. Source preprocessors edit the
normalized entry text before the reader interprets directives. Include processors
can supply bytes for a resolved target under the reader's access and size limits.
Block styles receive a preprocessed listing or literal body and can emit an
ordinary block, consume the input, or ask the parser to read child blocks.
Reference normalizers can rewrite a cross-reference target before resolution.
The link:acdc-parser/README.adoc#registered-extensions[parser guide] describes
the ordering and limits of these callbacks.

Block-macro recognition records invocations and their source-position attributes without
calling extension code during speculative grammar matching. The host runs macros
once at committed block boundaries in source order, applying requested attribute
changes before later conditionals and includes, then repairs captions and catalogs.
Tree processors run once in registration order through a scoped editor.

Queries return the same typed views as ordinary parser consumers, plus stable
handles for checked edits. Reference and footnote repair reuse the shared prepared
content services. Extension edits preserve surviving numbering. The host allocates
generated text; builders do not reparse it or store backend markup.

The working session retains deferred requests and document-local processors.
A tree processor registered with `TreeProcessorRegistration::for_macro` receives
its macro's surviving requests in source order. Only that processor can resolve
those placeholders. Removing a containing section cancels its pending requests.
Its checked `finish()` operation rejects unresolved requests and returns the
ordinary `ParseResult` for conversion. Registrations are explicit, and an empty
registry retains the ordinary parsing path. Callback attribute changes follow
the same assignment, locking, and nested-document policies as authored content.

`acdc-converters-core::pipeline` provides the shared library and CLI orchestration.
The backend is configured before parsing so its attributes govern source
processing. An `ExtensionCatalog` lists packages available in the application;
explicit selection activates them and rejects unavailable names before reading
input. Selected packages preserve selection order and their registration order.

`Pipeline` coordinates parser-owned source processing, committed callbacks,
tree processors, and finalization for strings, files, and readers. Conversion
prepares deferred display content and expands surviving registered inline macros
before calling the backend. A copied title or catalog label reuses the expansion
of its original invocation. CLI batches, stdin, terminal output, and pagers use these
same entry points. Inactive pipelines call the ordinary parser directly.

Working sessions permit checked edits through document-local handles. Borrowed
queries end before edits; fresh queries observe repaired catalogs and copied
selections remain snapshots. Surviving handles retain identity across insertions
and replacement; removed handles never bind to another block. `normalize()` is
idempotent without callbacks. `finish()` consumes the session, binds displays to
surviving targets, and rejects unresolved requests. Pipeline parsing returns only
the finalized `ParseResult`.

Factories may be shared; mutable handlers belong to each document. Each render
creates fresh counters, traversal state, and display overlays without mutating
parsed storage. Parser and converter warnings remain structured until presented
by the caller. Processor errors stop later work. Checked edits are atomic, but
earlier successful edits and external callback effects cannot be rolled back as
a sequence.

Native block renderers are also immutable registrations with fresh mutable
handlers per conversion. `Extensions` combines parser and renderer capabilities;
renderer-only selections retain ordinary parsing. Backends dispatch selected
renderers in order and use ordinary rendering when every handler declines.
An accepting renderer can replace the block or delegate once to wrap the output
of the remaining renderers and the backend.
HTML supplies streaming output, diagnostics, metadata escaping, and caption/title
services. Renderers read attributes from the active traversal so accepted body
assignments apply in source order and cell-local values expire on exit. Selected
renderers supply their CSP script hashes. No handler can edit the shared parsed
document through this rendering interface.

Full HTML documents run docinfo hooks at the head, header, and footer, after
file-based docinfo at each position. A hook supplies trusted backend markup and
escapes any document values it inserts. For converters that support UTF-8 text
output, selecting a postprocessor buffers the completed document. Postprocessors
edit it in registration order before the pipeline writes it to the destination.

==== Inline preprocessing

Inline content needs special handling, as specified in https://gitlab.eclipse.org/eclipse/asciidoc-lang/asciidoc-lang/-/blob/main/spec/sdrs/sdr-005-formal-grammar-for-inline-syntax.adoc[SDR-005: Formal Grammar for Inline Syntax].
Expand Down Expand Up @@ -146,7 +223,7 @@ Programmatically constructed nodes can carry caller-supplied or default location
=== Stage 3: converters

Converters (`converters/`) transform the AST into various output formats.
They implement the `Processable` trait in link:converters/core/src/lib.rs[`converters/core`].
They implement the `Converter` trait in link:converters/core/src/lib.rs[`converters/core`].
The trait owns converter setup and conversion; parser options are validated before parsing.

The converters are:
Expand Down Expand Up @@ -264,23 +341,17 @@ Reindented includes retain preprocessed byte offsets, so use their original line

=== Adding new converters

If you want to add a new converter, implement the `Processable` trait. The trait requires:

* `document_attributes_defaults()` - Provide converter-specific default attributes (optional override)
* `new()` - Initialize the converter with its options and a parser options builder
* `convert()` - Convert a parsed document, writing output to the destination
* `document_attributes()` - Access the document attributes

The best way to understand how this works is to look at an existing converter.
The Terminal converter (`converters/terminal/src/lib.rs`) is a good starting point - it's relatively straightforward and shows all the essential patterns.

To add a new converter:

. Create a new crate under `converters/`
. Add dependencies on `acdc-converters-core` and `acdc-parser`
. Define your options and error types
. Implement the `Processable` trait
. Walk the AST to generate your output format
Implement `acdc_converters_core::Converter` in a crate under `converters/`.
Its constructor configures the parser options, including the backend's intrinsic
attributes. Its `write_to()` method renders a prepared document to the supplied
writer and reports warnings through the diagnostic sink. The
link:converters/terminal/src/lib.rs[terminal converter] implements this contract.

To expose a statically linked converter by name, publish a `ConverterSpec` with
its canonical name, aliases, and supported variants. The application registers
the spec and its runner in a `ConverterRegistry`. It resolves the selection
before reading input so only the selected runner constructs a converter.
See the link:converters/core/src/registry.rs[registration example].

=== Adding new grammar rules

Expand Down
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions acdc-cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- Statically linked converter registrations now supply the available backend names, aliases, and variants for CLI help and conversion.

- Selected native text postprocessors run per input, including when multiple terminal documents share a pager.

- Conversion accepts repeatable `--extension NAME` selections and rejects
unavailable packages before reading input. All input and output routes share
the backend-aware library pipeline.

- Conversion continues after recoverable parser errors and reports structured
warnings, including non-conforming manpage titles. `convert --fail-on-warnings`
retains successful output, processes the remaining selected inputs, and exits
Expand Down
13 changes: 13 additions & 0 deletions acdc-cli/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,19 @@ Supported backends depend on the features used to build the binary:

`--backend html5s` remains an alias for `--backend html --variant semantic`.

==== Extension selection

`--extension NAME` explicitly selects a named extension package registered by the
application. Repeat the option to select multiple packages in execution order;
duplicate selections count once. Compiling or registering a package does not
activate it. Unknown or unavailable names fail before input is read or parsed.

Files, stdin, batches, terminal output, and pager output use the same pipeline.
The selected backend supplies attributes before preprocessing, and every document
gets fresh extension handlers. Library callers use
`acdc_converters_core::pipeline::Pipeline` and `ExtensionCatalog` for the same
behavior; see link:../converters/README.adoc[the converter guide].

==== Input and output

Without `--out-file`, file input produces a backend-specific path next to each input.
Expand Down
Loading
Loading