@dogsbay/adoc2md-modular 0.2.0-beta.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LINEAGE.md +67 -0
- package/README.md +38 -0
- package/dist/engine.d.ts +9 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +2075 -0
- package/dist/engine.js.map +1 -0
- package/dist/index.d.ts +106 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +52 -0
- package/dist/index.js.map +1 -0
- package/package.json +39 -0
package/LINEAGE.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# LINEAGE
|
|
2
|
+
|
|
3
|
+
`packages/adoc2md-modular/src/engine.js` is a fork of [downdoc](https://gitlab.com/antora/downdoc) by Dan Allen (Apache-2.0), substantially modified by the `~/dev/md2md` prototype, then carried into Dogsbay verbatim during Phase 4 of [`plans/format-asciidoc-import.md`](../../plans/format-asciidoc-import.md).
|
|
4
|
+
|
|
5
|
+
**Date copied into Dogsbay:** 2026-05-13.
|
|
6
|
+
**Source file:** `~/dev/md2md/src/downdoc.js` (the md2md prototype's modified fork — not the upstream downdoc).
|
|
7
|
+
**Size:** 2069 lines.
|
|
8
|
+
**License:** Apache-2.0 (inherited from downdoc upstream).
|
|
9
|
+
|
|
10
|
+
## Why we forked
|
|
11
|
+
|
|
12
|
+
Upstream downdoc handles single-file AsciiDoc → Markdown conversion well. The md2md prototype's fork extends it for **modular-content** workflows — the patterns Red Hat (AAP, OpenShift) and Antora-style doc sites use heavily:
|
|
13
|
+
|
|
14
|
+
- `include::` directives in a multi-file corpus (with `leveloffset` adjustment)
|
|
15
|
+
- `ifdef::`/`ifndef::` conditionals where the attribute context is supplied at convert time (or preserved for later resolution)
|
|
16
|
+
- Document-level `:attr: value` declarations interleaved with prose
|
|
17
|
+
- Attribute references `{name}` resolved against a layered attribute context
|
|
18
|
+
|
|
19
|
+
The fork's strategy is to **emit Minja directives** for the constructs that depend on a runtime context — `{{ name }}` for attribute refs, `{% if name %}…{% endif %}` for conditionals, `{% include "./<path>.md" %}` for includes, `{% set name = "value" %}` for in-doc attribute entries. Downstream [`@dogsbay/minja`](../minja/) then evaluates those directives with the actual context. This two-stage pipeline keeps the AsciiDoc-syntax converter free of I/O and runtime-state concerns.
|
|
20
|
+
|
|
21
|
+
## Changes from upstream downdoc
|
|
22
|
+
|
|
23
|
+
The md2md `docs-dev/DESIGN-DECISIONS.md` + `GOTCHAS.md` documents enumerate the modifications. Key surface-level deltas the test suite locked in:
|
|
24
|
+
|
|
25
|
+
| Change | Where (rough) | Why |
|
|
26
|
+
|---|---|---|
|
|
27
|
+
| Attribute refs `{name}` always emit `{{ name }}` Minja vars (never inline-substitute) | `applySubs` / `attributes()` path | Two-stage pipeline — Minja resolves at render time. |
|
|
28
|
+
| `:name: value` entries emit `{%- set name = "value" %}` | Top-level attribute-entry handler | Preserves attribute scope through includes. |
|
|
29
|
+
| `ifdef::name[]` / `ifndef::name[]` / `endif::[]` emit `{% if … %}…{% endif %}` (never evaluated inline) | Preprocessor-directive path | Minja evaluates with runtime context. |
|
|
30
|
+
| `include::path.adoc[]` emits `{% include "./path.md" %}` (extension auto-converted) when `nunjucksIncludes=true` | `resolveIncludes` | Pipeline emits Markdown; included sibling will also be Markdown. |
|
|
31
|
+
| Smart indentation for includes (top-level list items get special handling) | `resolveIncludes` | Avoids breaking list semantics across include boundaries. |
|
|
32
|
+
| Custom ID format `{id="..."}` on sub-headings | Heading emitter | Markdown-it-compatible; supports stable anchors. |
|
|
33
|
+
| 4-space list indentation | Constant `markdown-list-indent=4` | Mirrors mkdocs-material's canonical form. |
|
|
34
|
+
| Permissive empty-line handling | Various block parsers | Real-world AAP / OpenShift docs are quirky. |
|
|
35
|
+
| UI macros (`btn`, `kbd`, `menu`) converted to HTML | Inline macro path | Cross-renderer compatibility. |
|
|
36
|
+
| `:!aws:` AsciiDoc unset → `{% set aws = false %}` | Attribute-entry handler | Minja-friendly representation of unset. |
|
|
37
|
+
| List numbering uses uniform `1.` (not incremented) | List emitter | Cleaner version-control diffs. |
|
|
38
|
+
| Admonitions: line-form (`NOTE: …`) always HTML-ish (`**📌 NOTE**\`); only block-form (`[NOTE]\n====\n…\n====`) respects `admonitionFormat` | Admonition emitter | Line-form is a single-line construct; block-form is the configurable surface. |
|
|
39
|
+
|
|
40
|
+
## What we changed during the Dogsbay port
|
|
41
|
+
|
|
42
|
+
Minimal — kept the engine as plain JS to minimise regression risk:
|
|
43
|
+
|
|
44
|
+
1. **CommonJS → ESM**: 4 lines at the top of the file.
|
|
45
|
+
- `'use strict'` → removed (ESM is strict)
|
|
46
|
+
- `const fs = require('fs')` → `import fs from 'node:fs'`
|
|
47
|
+
- `const path = require('path')` → `import path from 'node:path'`
|
|
48
|
+
- `module.exports = function downdoc (…)` → `export default function downdoc (…)`
|
|
49
|
+
2. **`engine.d.ts`** hand-written for the public surface (`EngineOptions` + default export).
|
|
50
|
+
3. **No other code edits.** The 2069 lines of converter logic are byte-identical to the md2md prototype.
|
|
51
|
+
|
|
52
|
+
## How to update from md2md upstream
|
|
53
|
+
|
|
54
|
+
`md2md` is treated as a read-only reference per `plans/format-asciidoc-import.md`. There's no auto-sync. To pull a new revision:
|
|
55
|
+
|
|
56
|
+
1. Diff `~/dev/md2md/src/downdoc.js` against `packages/adoc2md-modular/src/engine.js`.
|
|
57
|
+
2. Apply the substantive changes (skipping the 4-line ESM patch above — those stay).
|
|
58
|
+
3. Re-run `pnpm --filter @dogsbay/adoc2md-modular test`.
|
|
59
|
+
4. Update this LINEAGE.md with the new source date + change summary.
|
|
60
|
+
|
|
61
|
+
## Attribution
|
|
62
|
+
|
|
63
|
+
- Upstream: [Dan Allen / downdoc](https://gitlab.com/antora/downdoc) — Apache-2.0.
|
|
64
|
+
- Prototype: `~/dev/md2md/src/downdoc.js` (the modified fork). md2md authors carried the upstream license.
|
|
65
|
+
- Phase 4 Dogsbay port: Gabriel McGoldrick (the same prototype author), 2026-05-13.
|
|
66
|
+
|
|
67
|
+
License is preserved as Apache-2.0 for `engine.js`; the rest of the package (`index.ts`, `engine.d.ts`, tests, docs) is MIT (the dogsbay default).
|
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# @dogsbay/adoc2md-modular
|
|
2
|
+
|
|
3
|
+
AsciiDoc → Markdown converter optimised for **modular-content** patterns: `include::` resolution, `:leveloffset:` adjustment, `ifdef::` conditionals, attribute substitution. Ported from the [`md2md`](https://github.com/dogsbay/md2md) prototype's `downdoc.js`; the per-file engine that `@dogsbay/format-asciidoc` builds on.
|
|
4
|
+
|
|
5
|
+
> **Phase 3 status:** scaffold only. Public API is shaped; the body is a stub that returns the input unchanged. Phase 4 will land the real converter ported from `md2md/src/downdoc.js`. Not safe to consume in a pipeline yet.
|
|
6
|
+
|
|
7
|
+
## API
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { asciidocToMarkdown } from "@dogsbay/adoc2md-modular";
|
|
11
|
+
|
|
12
|
+
const md = asciidocToMarkdown(adocSource, {
|
|
13
|
+
attributes: { product: "AAP", version: "2.5" },
|
|
14
|
+
inlineIncludes: false, // default — emit {% include %}
|
|
15
|
+
dlistFormat: "markdown", // markdown | html | pandoc
|
|
16
|
+
admonitionFormat: "html", // html | mkdocs | docusaurus | github
|
|
17
|
+
});
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Output is Markdown with Minja directives embedded for unresolved variables and includes. Resolve them downstream with `@dogsbay/minja` (see `plans/format-asciidoc-import.md` Phase 2 for the `undefinedBehavior` modes that let unresolved attributes survive into the final artifact).
|
|
21
|
+
|
|
22
|
+
## Why a separate package?
|
|
23
|
+
|
|
24
|
+
Three concerns are intertwined in AsciiDoc import and each deserves its own surface:
|
|
25
|
+
|
|
26
|
+
1. **Per-file converter** (this package): AsciiDoc syntax → Markdown text. Pure function, no I/O, no corpus topology.
|
|
27
|
+
2. **Preprocessor** (`@dogsbay/minja`): variable + include resolution against an attribute context.
|
|
28
|
+
3. **Corpus loader** (`@dogsbay/format-asciidoc`): discovery + topology — which files exist, what variants apply, how nav is built. See `plans/asciidoc-corpus-loaders.md`.
|
|
29
|
+
|
|
30
|
+
Keeping the converter free of I/O and topology means it round-trips deterministically and stays easy to test against the md2md fixtures.
|
|
31
|
+
|
|
32
|
+
## Lineage
|
|
33
|
+
|
|
34
|
+
Forked from Dan Allen's [downdoc](https://gitlab.com/antora/downdoc) via the `md2md` prototype. See `LINEAGE.md` (to be added in Phase 4) for the upstream fork point and enumerated local modifications.
|
|
35
|
+
|
|
36
|
+
## Roadmap
|
|
37
|
+
|
|
38
|
+
See [`plans/format-asciidoc-import.md`](../../plans/format-asciidoc-import.md) for the 8-phase rollout. This package owns Phases 3–5.
|
package/dist/engine.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export default function downdoc(asciidoc: any, { attributes: initialAttrs, basePath, cleanupContinuation, nunjucksIncludes, dlistFormat, admonitionFormat }?: {
|
|
2
|
+
attributes?: {} | undefined;
|
|
3
|
+
basePath?: null | undefined;
|
|
4
|
+
cleanupContinuation?: boolean | undefined;
|
|
5
|
+
nunjucksIncludes?: boolean | undefined;
|
|
6
|
+
dlistFormat?: string | undefined;
|
|
7
|
+
admonitionFormat?: string | undefined;
|
|
8
|
+
}): any;
|
|
9
|
+
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.js"],"names":[],"mappings":"AA+4CA;;;;;;;QAwfC"}
|