@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/dist/parse.js ADDED
@@ -0,0 +1,295 @@
1
+ import { parseDocument } from "htmlparser2";
2
+ import { convertChildren } from "./blocks.js";
3
+ import { textOf, convertInline, trimInline, collapseWhitespace } from "./inline.js";
4
+ import { DITA_TOPIC_TYPES, relativeIncludePath, } from "./types.js";
5
+ const isElement = (node) => node.type === "tag";
6
+ /**
7
+ * Collect ALL topic elements at the shallowest level they appear —
8
+ * multi-topic composites (<dita> wrappers, chunked files) have sibling
9
+ * topics alongside the primary one.
10
+ */
11
+ const findTopicRoots = (nodes) => {
12
+ const roots = [];
13
+ for (const node of nodes) {
14
+ if (!isElement(node))
15
+ continue;
16
+ const name = node.name.toLowerCase();
17
+ if (DITA_TOPIC_TYPES.includes(name)) {
18
+ roots.push(node);
19
+ continue; // nested topics inside this root are handled during conversion
20
+ }
21
+ roots.push(...findTopicRoots(node.children));
22
+ }
23
+ return roots;
24
+ };
25
+ /**
26
+ * Convert a secondary topic (nested or sibling) inline as a section:
27
+ * its title becomes a heading carrying the topic's @id as the anchor —
28
+ * which is exactly where renamed `file.md#topicid` links land — followed
29
+ * by its shortdesc, body, and recursively any topics nested inside it.
30
+ */
31
+ const convertSecondaryTopic = (el, ctx, level, bindConrefSite) => {
32
+ const out = [];
33
+ const bodyLevel = Math.min(6, level + 1);
34
+ // Conref resolution is topic-scoped (`#./elemid`, defining-site ids) —
35
+ // rebind the site context to THIS topic's id
36
+ const inner = {
37
+ ...ctx,
38
+ headingLevel: bodyLevel,
39
+ ...(bindConrefSite ? { conref: bindConrefSite(el.attribs?.id) } : {}),
40
+ };
41
+ let headingEmitted = false;
42
+ // Whole-topic conref on a nested/sibling topic — same ledger rule as
43
+ // the primary root (see ditaTopicToTree)
44
+ if (el.attribs?.conref || el.attribs?.conkeyref) {
45
+ const ref = el.attribs.conref ?? el.attribs.conkeyref;
46
+ ctx.note(el.attribs.conref ? "@conref" : "@conkeyref", `<${el.name.toLowerCase()}> pulls an entire topic from "${ref}" — whole-topic conrefs are not auto-converted; include the converted target page manually`);
47
+ }
48
+ for (const child of el.children) {
49
+ if (!isElement(child))
50
+ continue;
51
+ const name = child.name.toLowerCase();
52
+ if (name === "title" || name === "glossterm") {
53
+ out.push({
54
+ type: "heading",
55
+ props: {
56
+ level,
57
+ ...(el.attribs?.id ? { id: el.attribs.id } : {}),
58
+ },
59
+ inline: trimInline(convertInline(child.children, inner)),
60
+ ...(el.attribs?.id ? { meta: { dita: { id: el.attribs.id } } } : {}),
61
+ });
62
+ headingEmitted = true;
63
+ continue;
64
+ }
65
+ if (name === "titlealts")
66
+ continue;
67
+ if (DITA_TOPIC_TYPES.includes(name)) {
68
+ out.push(...convertSecondaryTopic(child, ctx, bodyLevel, bindConrefSite));
69
+ continue;
70
+ }
71
+ out.push(...convertChildren({ ...el, children: [child] }, inner));
72
+ }
73
+ // Title-less topics still need their id anchor — renamed links target it
74
+ if (!headingEmitted && el.attribs?.id) {
75
+ out.unshift({
76
+ type: "html",
77
+ html: `<a id="${el.attribs.id.replace(/"/g, "&quot;")}"></a>`,
78
+ });
79
+ }
80
+ return out;
81
+ };
82
+ /** Direct text of an element, excluding nested element content. */
83
+ const directText = (el) => collapseWhitespace(el.children
84
+ .filter((c) => c.type === "text")
85
+ .map((c) => c.data)
86
+ .join("")).trim();
87
+ /** Full text of an element, whitespace-collapsed (prolog values are YAML-bound). */
88
+ const cleanText = (el) => collapseWhitespace(textOf(el.children)).trim();
89
+ /**
90
+ * Extract <prolog> metadata into topic meta (frontmatter-bound):
91
+ * authors, critdates, keywords/indexterms → tags, categories. Elements
92
+ * with no frontmatter representation stay on the ledger — known loss.
93
+ */
94
+ const extractProlog = (el, meta, ctx) => {
95
+ const noteDropped = (name, detail = "prolog metadata not representable in frontmatter — dropped") => {
96
+ const construct = `<prolog>/<${name}>`;
97
+ if (ctx.seenConstructs.has(construct))
98
+ return;
99
+ ctx.seenConstructs.add(construct);
100
+ ctx.note(construct, detail);
101
+ };
102
+ const push = (key, value, elementName) => {
103
+ if (!value) {
104
+ // Attribute-only / empty elements carry data we can't extract —
105
+ // known loss, never silent loss
106
+ noteDropped(elementName, "element has no text content — dropped (attribute-only metadata not extracted)");
107
+ return;
108
+ }
109
+ const list = (meta[key] ??= []);
110
+ if (!list.includes(value))
111
+ list.push(value);
112
+ };
113
+ const walkMetadata = (metadataEl) => {
114
+ for (const child of metadataEl.children.filter(isElement)) {
115
+ const name = child.name.toLowerCase();
116
+ if (name === "keywords") {
117
+ for (const kw of child.children.filter(isElement)) {
118
+ const kwName = kw.name.toLowerCase();
119
+ if (kwName === "keyword" || kwName === "indexterm") {
120
+ // Nested indexterms are index-entry hierarchies; the tag is
121
+ // the top-level term's own text
122
+ push("tags", kwName === "keyword" ? cleanText(kw) : directText(kw), kwName);
123
+ }
124
+ else {
125
+ noteDropped(kwName);
126
+ }
127
+ }
128
+ }
129
+ else if (name === "category") {
130
+ push("categories", cleanText(child), "category");
131
+ }
132
+ else if (name === "metadata") {
133
+ walkMetadata(child);
134
+ }
135
+ else {
136
+ noteDropped(name);
137
+ }
138
+ }
139
+ };
140
+ for (const child of el.children.filter(isElement)) {
141
+ const name = child.name.toLowerCase();
142
+ if (name === "author") {
143
+ push("authors", cleanText(child), "author");
144
+ }
145
+ else if (name === "critdates") {
146
+ for (const date of child.children.filter(isElement)) {
147
+ const dateName = date.name.toLowerCase();
148
+ if (dateName === "created" && date.attribs?.date) {
149
+ meta.created = date.attribs.date;
150
+ }
151
+ else if (dateName === "revised" && date.attribs?.modified) {
152
+ meta.revised = date.attribs.modified;
153
+ }
154
+ else {
155
+ // Missing expected attribute, or a date form we don't read
156
+ // (golive/expiry, text-content dates) — ledger it
157
+ noteDropped(dateName, `critdates <${dateName}> without the expected date/modified attribute — dropped`);
158
+ }
159
+ }
160
+ }
161
+ else if (name === "metadata") {
162
+ walkMetadata(child);
163
+ }
164
+ else {
165
+ noteDropped(name);
166
+ }
167
+ }
168
+ };
169
+ /**
170
+ * Convert one DITA topic document to a TreeNode[] block tree plus topic
171
+ * metadata and a conversion-note ledger. Never throws on content problems.
172
+ *
173
+ * The primary topic's <title> becomes `meta.title` (page-level, not a
174
+ * block); <shortdesc> is both `meta.shortdesc` and the first paragraph.
175
+ * Additional topics — nested inside the primary or siblings under a
176
+ * composite (<dita>) wrapper — convert inline as heading-anchored sections,
177
+ * so multi-topic (chunked) files lose nothing.
178
+ */
179
+ export function ditaTopicToTree(xml, options = {}) {
180
+ const topicPath = options.topicPath ?? "";
181
+ const notes = [];
182
+ const note = (construct, detail) => notes.push({ topicPath, construct, detail });
183
+ const doc = parseDocument(xml, { xmlMode: true });
184
+ const roots = findTopicRoots(doc.children);
185
+ const root = roots[0] ?? null;
186
+ if (!root) {
187
+ note("<topic>", "no DITA topic root element found (concept/task/reference/topic/glossentry)");
188
+ return { tree: [], meta: {}, notes };
189
+ }
190
+ // Whole-topic conref on the root: the entire pulled body is absent
191
+ // here, and topic-level pulls are never auto-converted — ledger it so
192
+ // an (almost) empty page is never a silent mystery
193
+ if (root.attribs?.conref || root.attribs?.conkeyref) {
194
+ const ref = root.attribs.conref ?? root.attribs.conkeyref;
195
+ note(root.attribs.conref ? "@conref" : "@conkeyref", `<${root.name.toLowerCase()}> pulls an entire topic from "${ref}" — whole-topic conrefs are not auto-converted; include the converted target page manually`);
196
+ }
197
+ // Bind the corpus conref plan (if any) to this file: resolution is
198
+ // relative to the topic's corpus path, and topic-scoped for the
199
+ // `#./elemid` shorthand and defining-site lookups. The output .md
200
+ // lives in the same directory as the source topic, so include paths
201
+ // are computed from the topic's directory.
202
+ const topicDir = topicPath.includes("/") ? topicPath.slice(0, topicPath.lastIndexOf("/")) : "";
203
+ // DITA tolerates duplicate element ids inside one topic; the plan
204
+ // indexes the FIRST element per id, so only the first defining-site
205
+ // match may be replaced — a later same-id element with different
206
+ // content must convert normally, never splice the wrong snippet.
207
+ const claimedDefiningSites = new Set();
208
+ const bindConrefSite = options.conrefs
209
+ ? (topicId) => {
210
+ const plan = options.conrefs;
211
+ return {
212
+ resolve: (ref) => plan.resolve(ref, topicPath, topicId),
213
+ definingSnippet: (elementId) => {
214
+ if (!topicId)
215
+ return undefined;
216
+ const snippet = plan.extractionFor(topicPath, topicId, elementId);
217
+ if (!snippet)
218
+ return undefined;
219
+ const key = `${topicId}/${elementId}`;
220
+ if (claimedDefiningSites.has(key))
221
+ return undefined;
222
+ claimedDefiningSites.add(key);
223
+ return snippet;
224
+ },
225
+ includePath: (snippet) => relativeIncludePath(topicDir, snippet.file),
226
+ };
227
+ }
228
+ : undefined;
229
+ const ctx = {
230
+ note,
231
+ seenConstructs: new Set(),
232
+ headingLevel: 2,
233
+ ...(bindConrefSite ? { conref: bindConrefSite(root.attribs?.id) } : {}),
234
+ };
235
+ const meta = { ditaType: root.name.toLowerCase() };
236
+ if (root.attribs?.id)
237
+ meta.id = root.attribs.id;
238
+ const tree = [];
239
+ for (const child of root.children) {
240
+ if (!isElement(child))
241
+ continue;
242
+ const name = child.name.toLowerCase();
243
+ if (name === "title" || name === "glossterm") {
244
+ // glossentry topics carry their title in <glossterm>
245
+ meta.title = textOf(child.children).trim();
246
+ continue;
247
+ }
248
+ if (name === "shortdesc") {
249
+ meta.shortdesc = textOf(child.children).replace(/\s+/g, " ").trim();
250
+ tree.push(...convertChildren({ ...root, children: [child] }, ctx));
251
+ continue;
252
+ }
253
+ if (name === "titlealts")
254
+ continue;
255
+ if (name === "prolog") {
256
+ // Primary-topic prolog becomes frontmatter metadata instead of a
257
+ // wholesale ledger drop (secondary topics keep the ledger note —
258
+ // sections have no frontmatter)
259
+ extractProlog(child, meta, ctx);
260
+ continue;
261
+ }
262
+ if (DITA_TOPIC_TYPES.includes(name)) {
263
+ // Nested topic: convert inline as a section (chunked authoring)
264
+ tree.push(...convertSecondaryTopic(child, ctx, 2, bindConrefSite));
265
+ continue;
266
+ }
267
+ tree.push(...convertChildren({ ...root, children: [child] }, ctx));
268
+ }
269
+ // Sibling topics under a composite wrapper convert the same way
270
+ for (const sibling of roots.slice(1)) {
271
+ tree.push(...convertSecondaryTopic(sibling, ctx, 2, bindConrefSite));
272
+ }
273
+ // DITA element ids are unique per TOPIC, not per file — after inlining
274
+ // multiple topics, colliding ids mean fragment links can mis-target.
275
+ // Known loss, never silent loss: report every duplicate anchor.
276
+ const seenAnchorIds = new Set();
277
+ const walkIds = (nodes) => {
278
+ for (const node of nodes) {
279
+ const id = node.props?.id;
280
+ if (typeof id === "string") {
281
+ if (seenAnchorIds.has(id)) {
282
+ note("duplicate-id", `anchor id "${id}" appears in more than one inlined topic — fragment links to it may land on the wrong section; rename one of the ids`);
283
+ }
284
+ else {
285
+ seenAnchorIds.add(id);
286
+ }
287
+ }
288
+ if (node.children)
289
+ walkIds(node.children);
290
+ }
291
+ };
292
+ walkIds(tree);
293
+ return { tree, meta, notes };
294
+ }
295
+ //# sourceMappingURL=parse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse.js","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,OAAO,EAAE,eAAe,EAAqB,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,EACL,gBAAgB,EAChB,mBAAmB,GAKpB,MAAM,YAAY,CAAC;AAEpB,MAAM,SAAS,GAAG,CAAC,IAAa,EAAmB,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC;AAE1E;;;;GAIG;AACH,MAAM,cAAc,GAAG,CAAC,KAAgB,EAAa,EAAE;IACrD,MAAM,KAAK,GAAc,EAAE,CAAC;IAC5B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;YA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,EAAE,CAAC;gBAC3B,IAAI,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;oBAC1B,IAAI,CACF,cAAc,EACd,cAAc,EAAE,sHAAsH,CACvI,CAAC;gBACJ,CAAC;qBAAM,CAAC;oBACN,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBACxB,CAAC;YACH,CAAC;YACD,IAAI,IAAI,CAAC,QAAQ;gBAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC;IAEd,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,105 @@
1
+ import type { TreeNode } from "@dogsbay/types";
2
+ /**
3
+ * One conversion note — the content-level fidelity ledger. Anything DITA
4
+ * expresses that TreeNode cannot carry (or that needs a human decision)
5
+ * lands here: known loss, never silent loss.
6
+ */
7
+ export interface DitaConversionNote {
8
+ /** Topic path or "" for inline sources. */
9
+ topicPath: string;
10
+ /** Construct that triggered the note (element/attribute name). */
11
+ construct: string;
12
+ detail: string;
13
+ }
14
+ /** Topic-level metadata extracted alongside the block tree. */
15
+ export interface DitaTopicMeta {
16
+ /** @id of the topic root. */
17
+ id?: string;
18
+ /** <title> text. */
19
+ title?: string;
20
+ /** Root element name: concept | task | reference | topic | glossentry. */
21
+ ditaType?: string;
22
+ /** <shortdesc> text (also emitted as the first paragraph). */
23
+ shortdesc?: string;
24
+ /** <prolog><author> entries. */
25
+ authors?: string[];
26
+ /** <prolog><critdates><created @date>. */
27
+ created?: string;
28
+ /** <prolog><critdates><revised @modified> (last one wins). */
29
+ revised?: string;
30
+ /** <prolog> keywords/indexterms (top-level terms). */
31
+ tags?: string[];
32
+ /** <prolog><metadata><category> entries. */
33
+ categories?: string[];
34
+ }
35
+ export interface DitaTopicResult {
36
+ tree: TreeNode[];
37
+ meta: DitaTopicMeta;
38
+ notes: DitaConversionNote[];
39
+ }
40
+ /**
41
+ * Minimal view of an extracted reuse snippet, as consulted during
42
+ * conversion (the full ConrefSnippet in conref.ts adds content and
43
+ * provenance; conversion sites only need placement facts).
44
+ */
45
+ export interface ConrefSnippetRef {
46
+ /** Snippet path relative to the conversion output root, e.g. "_conrefs/x.md". */
47
+ file: string;
48
+ /**
49
+ * Single-line snippets are the only ones safe to include inside
50
+ * per-line-prefixed or indented markdown contexts (list items, steps,
51
+ * table cells, GitHub-form callouts, blockquotes) — minja splices file
52
+ * content verbatim, without re-indenting.
53
+ */
54
+ singleLine: boolean;
55
+ /** Level of the shallowest heading in the snippet, if it contains headings. */
56
+ headingBase?: number;
57
+ /**
58
+ * True when the snippet itself renders an anchor for the extracted
59
+ * element's @id (section/example targets: the heading carries {#id}).
60
+ * Defining sites skip their extra <a id> anchor in that case.
61
+ */
62
+ carriesAnchor: boolean;
63
+ }
64
+ /** Corpus-level conref plan surface consulted during topic conversion. */
65
+ export interface ConrefPlanApi {
66
+ /**
67
+ * Resolve a conref attribute value from a referencing topic.
68
+ * `fromTopicPath` must be the same corpus-relative posix path the file
69
+ * was registered under in planConrefs; `currentTopicId` resolves the
70
+ * `#./elemid` same-topic shorthand.
71
+ */
72
+ resolve(ref: string, fromTopicPath: string, currentTopicId?: string): ConrefSnippetRef | undefined;
73
+ /** Snippet extracted FROM the given element, if any (defining site). */
74
+ extractionFor(topicPath: string, topicId: string, elementId: string): ConrefSnippetRef | undefined;
75
+ }
76
+ /** Per-conversion-site view of the plan, pre-bound to the emitting file. */
77
+ export interface ConrefSiteContext {
78
+ /** Resolve a conref value in the current topic's context; undefined → ledger. */
79
+ resolve(ref: string): ConrefSnippetRef | undefined;
80
+ /** Snippet extracted from the element with this id in the current topic. */
81
+ definingSnippet(elementId: string): ConrefSnippetRef | undefined;
82
+ /** Include path for a snippet, relative to the emitting file's directory. */
83
+ includePath(snippet: ConrefSnippetRef): string;
84
+ }
85
+ export interface DitaParseOptions {
86
+ /** Used in conversion notes so multi-file runs stay attributable. */
87
+ topicPath?: string;
88
+ /**
89
+ * Corpus conref plan (see planConrefs). When set, `topicPath` must
90
+ * match the corpus-relative posix path used when building the plan.
91
+ */
92
+ conrefs?: ConrefPlanApi;
93
+ }
94
+ /** DITA topic root elements this importer understands. */
95
+ export declare const DITA_TOPIC_TYPES: readonly ["concept", "task", "reference", "topic", "glossentry"];
96
+ /**
97
+ * Relative path from one output-root-relative directory to an
98
+ * output-root-relative file, in posix form — the include path emitted
99
+ * into `{% include "…" %}` directives. Minja resolves include paths
100
+ * against the including file's directory at every nesting level.
101
+ */
102
+ export declare const relativeIncludePath: (fromDir: string, targetFile: string) => string;
103
+ /** article.dita / article.xml → article.md (same rule as import-ditamap). */
104
+ export declare const renameDitaHref: (href: string) => string;
105
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,2CAA2C;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,kEAAkE;IAClE,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,+DAA+D;AAC/D,MAAM,WAAW,aAAa;IAC5B,6BAA6B;IAC7B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,0CAA0C;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8DAA8D;IAC9D,OAAO,CAAC,EAAE,MAAM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AED,0DAA0D;AAC1D,eAAO,MAAM,gBAAgB,kEAAmE,CAAC;AAEjG;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAI,SAAS,MAAM,EAAE,YAAY,MAAM,KAAG,MAQzE,CAAC;AAEF,6EAA6E;AAC7E,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,KAAG,MAa7C,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,34 @@
1
+ /** DITA topic root elements this importer understands. */
2
+ export const DITA_TOPIC_TYPES = ["concept", "task", "reference", "topic", "glossentry"];
3
+ /**
4
+ * Relative path from one output-root-relative directory to an
5
+ * output-root-relative file, in posix form — the include path emitted
6
+ * into `{% include "…" %}` directives. Minja resolves include paths
7
+ * against the including file's directory at every nesting level.
8
+ */
9
+ export const relativeIncludePath = (fromDir, targetFile) => {
10
+ const from = fromDir.split("/").filter((seg) => seg !== "" && seg !== ".");
11
+ const to = targetFile.split("/").filter((seg) => seg !== "" && seg !== ".");
12
+ let common = 0;
13
+ while (common < from.length && common < to.length - 1 && from[common] === to[common]) {
14
+ common++;
15
+ }
16
+ return "../".repeat(from.length - common) + to.slice(common).join("/");
17
+ };
18
+ /** article.dita / article.xml → article.md (same rule as import-ditamap). */
19
+ export const renameDitaHref = (href) => {
20
+ const [path, fragment] = href.split("#");
21
+ const renamed = path.replace(/\.(dita|xml)$/i, ".md");
22
+ if (!fragment)
23
+ return renamed;
24
+ // DITA fragments are "topicid/elementid"; element ids become heading
25
+ // anchors ({#id}), so drop the topic-id segment. A bare topic-id
26
+ // fragment is kept: secondary topics in multi-topic files render as
27
+ // heading sections anchored by their topic id (a primary-topic fragment
28
+ // simply lands at the top of the right page).
29
+ const parts = fragment.split("/");
30
+ return parts.length > 1
31
+ ? `${renamed}#${parts.slice(1).join("/")}`
32
+ : `${renamed}#${fragment}`;
33
+ };
34
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names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AAE,OAAO,OAAO,CAAC;IAC9B,qEAAqE;IACrE,iEAAiE;IACjE,oEAAoE;IACpE,wEAAwE;IACxE,8CAA8C;IAC9C,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAClC,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC;QACrB,CAAC,CAAC,GAAG,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAC1C,CAAC,CAAC,GAAG,OAAO,IAAI,QAAQ,EAAE,CAAC;AAC/B,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@dogsbay/format-dita",
3
+ "version": "0.2.0-beta.101",
4
+ "description": "DITA topic XML → TreeNode importer with conversion-note ledger; composes with format-dogsbay-md for .dita → .md migration",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md"
17
+ ],
18
+ "devDependencies": {
19
+ "@types/node": "^25.9.5",
20
+ "typescript": "^5.9.3",
21
+ "vitest": "^4.1.10"
22
+ },
23
+ "dependencies": {
24
+ "domhandler": "^5.0.3",
25
+ "htmlparser2": "^10.1.0",
26
+ "@dogsbay/format-dogsbay-md": "0.2.0-beta.101",
27
+ "@dogsbay/types": "0.2.0-beta.101"
28
+ },
29
+ "license": "MIT",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/dogsbay/dogsbay.git",
33
+ "directory": "packages/format-dita"
34
+ },
35
+ "homepage": "https://github.com/dogsbay/dogsbay/tree/main/packages/format-dita",
36
+ "bugs": {
37
+ "url": "https://github.com/dogsbay/dogsbay/issues"
38
+ },
39
+ "scripts": {
40
+ "build": "tsc",
41
+ "test": "vitest run",
42
+ "test:watch": "vitest"
43
+ }
44
+ }