@dogsbay/format-dita 0.2.0-beta.101
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/README.md +41 -0
- package/dist/blocks.d.ts +51 -0
- package/dist/blocks.d.ts.map +1 -0
- package/dist/blocks.js +734 -0
- package/dist/blocks.js.map +1 -0
- package/dist/conref.d.ts +28 -0
- package/dist/conref.d.ts.map +1 -0
- package/dist/conref.js +303 -0
- package/dist/conref.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/inline.d.ts +43 -0
- package/dist/inline.d.ts.map +1 -0
- package/dist/inline.js +281 -0
- package/dist/inline.js.map +1 -0
- package/dist/markdown.d.ts +12 -0
- package/dist/markdown.d.ts.map +1 -0
- package/dist/markdown.js +72 -0
- package/dist/markdown.js.map +1 -0
- package/dist/parse.d.ts +13 -0
- package/dist/parse.d.ts.map +1 -0
- package/dist/parse.js +295 -0
- package/dist/parse.js.map +1 -0
- package/dist/types.d.ts +105 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +34 -0
- package/dist/types.js.map +1 -0
- package/package.json +44 -0
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# @dogsbay/format-dita
|
|
2
|
+
|
|
3
|
+
Convert DITA topic XML to Dogsbay's TreeNode model — and, composed with
|
|
4
|
+
`@dogsbay/format-dogsbay-md`, straight to markdown.
|
|
5
|
+
|
|
6
|
+
```ts
|
|
7
|
+
import { ditaTopicToDogsbayMd } from "@dogsbay/format-dita";
|
|
8
|
+
|
|
9
|
+
const { markdown, meta, notes } = ditaTopicToDogsbayMd(xml, {
|
|
10
|
+
topicPath: "install/t-install.dita",
|
|
11
|
+
});
|
|
12
|
+
// markdown: frontmatter (title, contentType, prolog, dita provenance) + body
|
|
13
|
+
// notes: conversion ledger — known loss, never silent loss
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Or from the CLI, pairing with `import-ditamap` for a full migration:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
dogsbay import-ditamap docs/root.ditamap -o topicmaps --report maps.md
|
|
20
|
+
dogsbay import-dita docs/ -o content --report topics.md
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Tasks become native `:::steps`, notes become callouts, CALS and
|
|
24
|
+
simpletables become tables, `<xref href="x.dita">` becomes `[…](x.md)`,
|
|
25
|
+
and `keyref` links become `key:` links. Nested or sibling topics in
|
|
26
|
+
multi-topic files are emitted inline as anchored sections.
|
|
27
|
+
|
|
28
|
+
Directory imports build a corpus-level conref plan by default: resolvable
|
|
29
|
+
`conref="file.dita#topic/element"` targets are extracted once into
|
|
30
|
+
`_conrefs/*.md`, then both referencing sites and defining warehouse sites
|
|
31
|
+
emit `{% include %}` so one canonical copy of reused text survives. Use
|
|
32
|
+
`dogsbay import-dita --no-conref-includes` to keep conrefs on the ledger
|
|
33
|
+
instead.
|
|
34
|
+
|
|
35
|
+
Everything that cannot map cleanly lands in the conversion ledger instead
|
|
36
|
+
of disappearing: filter attributes, table spans, semantic-inline downgrades,
|
|
37
|
+
`conkeyref`, conref ranges/pushes, whole-topic conrefs, unresolved targets,
|
|
38
|
+
and unknown elements.
|
|
39
|
+
|
|
40
|
+
See `docs/dita-migration.md` and `plans/format-dita.md` for the migration
|
|
41
|
+
contract and implementation status.
|
package/dist/blocks.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DITA body elements → TreeNode blocks, in the dialect
|
|
3
|
+
* @dogsbay/format-dogsbay-md serializes (heading/paragraph/code/callout/
|
|
4
|
+
* lists/steps/deflist/table/figure/image).
|
|
5
|
+
*
|
|
6
|
+
* DITA element @id attributes are preserved under `meta.dita.id` for
|
|
7
|
+
* provenance (the dogsbay-md round-trip contract); constructs TreeNode
|
|
8
|
+
* cannot carry are recorded as conversion notes.
|
|
9
|
+
*/
|
|
10
|
+
import type { Element } from "domhandler";
|
|
11
|
+
import type { TreeNode } from "@dogsbay/types";
|
|
12
|
+
import { type InlineContext } from "./inline.js";
|
|
13
|
+
import type { ConrefSiteContext, ConrefSnippetRef } from "./types.js";
|
|
14
|
+
export interface BlockContext extends InlineContext {
|
|
15
|
+
/** Current heading depth for <section>/<example> titles. */
|
|
16
|
+
headingLevel: number;
|
|
17
|
+
/**
|
|
18
|
+
* True inside per-line-prefixed or indented serialization contexts
|
|
19
|
+
* (list items, steps, table cells, GitHub-form callouts, blockquotes).
|
|
20
|
+
* Multi-line `{% include %}` content splices verbatim and would break
|
|
21
|
+
* out of such structures, so constrained sites only accept single-line
|
|
22
|
+
* snippets.
|
|
23
|
+
*/
|
|
24
|
+
constrained?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The include directive for a snippet, wrapped in a scoped leveloffset
|
|
28
|
+
* when the snippet carries headings and the site's heading depth differs
|
|
29
|
+
* from the snippet's baked-in base level.
|
|
30
|
+
*/
|
|
31
|
+
export declare const includeDirective: (snippet: ConrefSnippetRef, site: ConrefSiteContext, headingLevel: number) => string;
|
|
32
|
+
/**
|
|
33
|
+
* One <step>/<substep>'s content: <cmd> as the leading inline run, the
|
|
34
|
+
* rest as block children. Shared by convertSteps (constrained context)
|
|
35
|
+
* and conref snippet extraction (standalone, unconstrained).
|
|
36
|
+
*/
|
|
37
|
+
export declare const convertStepContent: (stepEl: Element, ctx: BlockContext) => {
|
|
38
|
+
inline?: TreeNode["inline"];
|
|
39
|
+
children: TreeNode[];
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Standalone content of an item-level element (<li>, <step>, …) for
|
|
43
|
+
* conref snippet extraction: leading inline as a paragraph, block
|
|
44
|
+
* children after.
|
|
45
|
+
*/
|
|
46
|
+
export declare const convertItemContent: (el: Element, ctx: BlockContext) => TreeNode[];
|
|
47
|
+
/** Whether an element name converts as a standalone block (conref-extractable). */
|
|
48
|
+
export declare const isBlockTarget: (name: string) => boolean;
|
|
49
|
+
export declare function convertBlock(el: Element, ctx: BlockContext): TreeNode[];
|
|
50
|
+
export declare function convertChildren(el: Element, ctx: BlockContext, skip?: Set<string>): TreeNode[];
|
|
51
|
+
//# sourceMappingURL=blocks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../src/blocks.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,OAAO,EAAW,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAc,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAML,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEtE,MAAM,WAAW,YAAa,SAAQ,aAAa;IACjD,4DAA4D;IAC5D,YAAY,EAAE,MAAM,CAAC;IACrB;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAsCD;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAC3B,SAAS,gBAAgB,EACzB,MAAM,iBAAiB,EACvB,cAAc,MAAM,KACnB,MAOF,CAAC;AAyVF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAC7B,QAAQ,OAAO,EACf,KAAK,YAAY,KAChB;IAAE,MAAM,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAAC,QAAQ,EAAE,QAAQ,EAAE,CAAA;CA4BrD,CAAC;AAoBF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,IAAI,OAAO,EAAE,KAAK,YAAY,KAAG,QAAQ,EAQ3E,CAAC;AAiBF,mFAAmF;AACnF,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,KAAG,OAAmC,CAAC;AAEjF,wBAAgB,YAAY,CAAC,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,GAAG,QAAQ,EAAE,CAmTvE;AAED,wBAAgB,eAAe,CAC7B,EAAE,EAAE,OAAO,EACX,GAAG,EAAE,YAAY,EACjB,IAAI,GAAE,GAAG,CAAC,MAAM,CAAa,GAC5B,QAAQ,EAAE,CA6BZ"}
|