2026-06-04 12:18:30 +00:00
# Transform Internals
Audience: developers and LLM coding agents changing `internal/transform` or transform implementations.
2026-05-31 02:28:48 +00:00
## Purpose
2026-06-04 12:18:30 +00:00
`internal/transform` defines generated publication artifacts, transform request/response types, transform registry behavior, and transform identifiers. `internal/transform/markdown` implements Markdown-to-HTML generation.
## Inputs And Outputs
2026-05-31 02:28:48 +00:00
2026-06-04 12:18:30 +00:00
Inputs are a validated source bundle, source storage backend, and transform options supplied by publish planning. Outputs are generated artifact records containing destination path, source path, transform id, generated bytes, SHA-256 digest, and byte size.
2026-05-31 02:28:48 +00:00
2026-06-04 12:18:30 +00:00
## Boundaries
2026-05-31 02:28:48 +00:00
2026-06-04 12:18:30 +00:00
Transforms do not mutate source bundles, publish files, write destination state, choose destination actions, parse config, or inspect destinations. Publish planning decides whether generated outputs are selected and writes destination state later.
2026-05-31 04:06:48 +00:00
2026-06-04 12:18:30 +00:00
The Goldmark renderer contract is documented in `docs/integrations/markdown.md` .
2026-05-31 04:06:48 +00:00
2026-06-04 12:18:30 +00:00
## Config Fields Used
2026-05-31 02:28:48 +00:00
2026-06-04 12:18:30 +00:00
Transform packages do not read config directly. Publish planning passes effective `transform.markdown_to_html.mode` and `transform.markdown_to_html.input` values.
2026-05-31 02:28:48 +00:00
2026-06-04 12:18:30 +00:00
## Adapters Used
2026-05-31 02:28:48 +00:00
2026-06-04 12:18:30 +00:00
Transforms read source files through `internal/storage.Backend` . The Markdown implementation uses `github.com/yuin/goldmark` for rendering.
2026-05-31 04:07:49 +00:00
2026-06-04 12:18:30 +00:00
## State And Manifest Behavior
2026-05-31 04:06:48 +00:00
2026-06-04 12:18:30 +00:00
Transform outputs carry metadata later projected into destination state. Markdown sidecar mode renders manifest-listed `.md` files to same-directory `.html` outputs. Markdown index mode renders one selected Markdown source to `index.html` .
2026-05-31 04:06:48 +00:00
2026-06-04 12:18:30 +00:00
## Skip And Resume Behavior
2026-05-31 02:28:48 +00:00
2026-06-04 12:18:30 +00:00
Transforms have no skip/resume state. They are deterministic for the same source bytes and transform options.
2026-05-31 02:28:48 +00:00
2026-06-04 12:18:30 +00:00
## Failure Behavior
2026-05-31 03:30:08 +00:00
2026-06-04 12:18:30 +00:00
Registry registration fails for empty names, nil transformers, and duplicate names. Transform resolution fails when publish planning requests an unregistered transform. Markdown rendering fails on source read errors, renderer errors, unsafe configured input, missing manifest input, non-Markdown input, ambiguous index input, or absent Markdown inputs.
2026-05-31 02:28:48 +00:00
2026-06-04 12:18:30 +00:00
## Tests To Inspect
2026-05-31 04:06:48 +00:00
2026-06-04 12:18:30 +00:00
- `internal/transform/*_test.go`
- `internal/transform/markdown/*_test.go`
- `internal/publish/*_test.go`
2026-05-31 04:06:48 +00:00
2026-06-04 12:18:30 +00:00
## Architectural Invariants
2026-05-31 04:06:48 +00:00
- Source bundle files are never mutated by transforms.
- Generated outputs record destination path, source path, transform id, SHA-256, and size.
2026-06-04 12:18:30 +00:00
- Markdown sidecar naming changes only the `.md` suffix to `.html` .
2026-06-01 21:20:02 +00:00
- Markdown index mode always writes `index.html` .
2026-06-04 12:18:30 +00:00
- Non-Markdown source files do not generate sidecar outputs.
2026-05-31 04:06:48 +00:00
- Transform registration stays outside publish planning.