@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/dist/inline.js
ADDED
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import { renameDitaHref } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* A snippet is safe to splice INLINE (mid-sentence, list items, cells)
|
|
4
|
+
* only when it is a single line with no heading — anything else breaks
|
|
5
|
+
* the surrounding markdown structure when minja inlines it verbatim.
|
|
6
|
+
*/
|
|
7
|
+
export const inlineSafeSnippet = (snippet) => snippet.singleLine && snippet.headingBase === undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Ledger detail for a conref that could not become an automatic include.
|
|
10
|
+
* When the target WAS extracted (snippet exists) the note names the
|
|
11
|
+
* snippet file so the manual fix is one paste away.
|
|
12
|
+
*/
|
|
13
|
+
export const conrefLedgerDetail = (attribs, snippet, hasPlan) => {
|
|
14
|
+
if (attribs?.conaction) {
|
|
15
|
+
return `conref push (conaction="${attribs.conaction}") injects content INTO the target — apply the push manually`;
|
|
16
|
+
}
|
|
17
|
+
if (attribs?.conkeyref) {
|
|
18
|
+
return "key-based content reference (conkeyref) needs its map's key space — convert to a minja include manually";
|
|
19
|
+
}
|
|
20
|
+
if (attribs?.conrefend) {
|
|
21
|
+
return "conref ranges (conrefend) are not auto-converted — merge the range into an include manually";
|
|
22
|
+
}
|
|
23
|
+
if (snippet) {
|
|
24
|
+
return `reused content is multi-line and this site cannot splice it — include "${snippet.file}" manually`;
|
|
25
|
+
}
|
|
26
|
+
if (hasPlan) {
|
|
27
|
+
return "no auto-include possible (target outside the corpus, unresolved, or not an extractable element) — convert to a minja include manually";
|
|
28
|
+
}
|
|
29
|
+
return "convert to a minja include manually";
|
|
30
|
+
};
|
|
31
|
+
const isElement = (node) => node.type === "tag";
|
|
32
|
+
const isText = (node) => node.type === "text";
|
|
33
|
+
/** Collapse XML whitespace runs the way HTML rendering would. */
|
|
34
|
+
export const collapseWhitespace = (text) => text.replace(/\s+/g, " ");
|
|
35
|
+
const noteOnce = (ctx, construct, detail) => {
|
|
36
|
+
if (ctx.seenConstructs.has(construct))
|
|
37
|
+
return;
|
|
38
|
+
ctx.seenConstructs.add(construct);
|
|
39
|
+
ctx.note(construct, detail);
|
|
40
|
+
};
|
|
41
|
+
/** Elements rendered as inline code (monospace semantics in DITA). */
|
|
42
|
+
const CODE_LIKE = new Set([
|
|
43
|
+
"codeph", "filepath", "cmdname", "apiname", "varname", "synph", "systemoutput", "userinput", "tt", "parmname",
|
|
44
|
+
// XML-domain elements (heavy in tooling docs like DITA-OT's)
|
|
45
|
+
"xmlelement", "xmlatt", "xmlnsname", "xmlpi", "numcharref", "parameterentity", "textentity", "msgph",
|
|
46
|
+
]);
|
|
47
|
+
/** Elements whose semantic identity is dropped; text passes through. */
|
|
48
|
+
const TRANSPARENT = new Set(["ph", "keyword", "text", "option", "msgnum"]);
|
|
49
|
+
const ITALIC_LIKE = new Set(["i", "term", "cite", "q", "var"]);
|
|
50
|
+
const BOLD_LIKE = new Set(["b", "uicontrol", "wintitle", "menucascade", "shortcut"]);
|
|
51
|
+
export const textOf = (nodes) => nodes
|
|
52
|
+
.map((node) => {
|
|
53
|
+
if (isText(node))
|
|
54
|
+
return node.data;
|
|
55
|
+
if (isElement(node))
|
|
56
|
+
return textOf(node.children);
|
|
57
|
+
return "";
|
|
58
|
+
})
|
|
59
|
+
.join("");
|
|
60
|
+
export const convertInline = (nodes, ctx, formatting = {}) => {
|
|
61
|
+
const out = [];
|
|
62
|
+
const pushText = (text) => {
|
|
63
|
+
if (text.length === 0)
|
|
64
|
+
return;
|
|
65
|
+
const prev = out[out.length - 1];
|
|
66
|
+
// Merge adjacent spans with identical formatting
|
|
67
|
+
if (prev?.type === "text" &&
|
|
68
|
+
!!prev.bold === !!formatting.bold &&
|
|
69
|
+
!!prev.italic === !!formatting.italic &&
|
|
70
|
+
!!prev.strikethrough === !!formatting.strikethrough) {
|
|
71
|
+
prev.text += text;
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const span = { type: "text", text };
|
|
75
|
+
if (formatting.bold)
|
|
76
|
+
span.bold = true;
|
|
77
|
+
if (formatting.italic)
|
|
78
|
+
span.italic = true;
|
|
79
|
+
if (formatting.strikethrough)
|
|
80
|
+
span.strikethrough = true;
|
|
81
|
+
out.push(span);
|
|
82
|
+
};
|
|
83
|
+
for (const node of nodes) {
|
|
84
|
+
if (isText(node)) {
|
|
85
|
+
pushText(collapseWhitespace(node.data));
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (!isElement(node))
|
|
89
|
+
continue;
|
|
90
|
+
const name = node.name.toLowerCase();
|
|
91
|
+
const children = node.children;
|
|
92
|
+
// Filter attributes FIRST: the include/defining-site paths below
|
|
93
|
+
// `continue` past the rest of the loop, and a profiled element that
|
|
94
|
+
// becomes an include still needs its condition on the ledger
|
|
95
|
+
for (const attr of ["audience", "platform", "product", "props", "otherprops", "rev"]) {
|
|
96
|
+
if (node.attribs?.[attr]) {
|
|
97
|
+
noteOnce(ctx, `@${attr}`, `<${name}> ${attr}="${node.attribs[attr]}" — map to a profile condition (ifdef) manually`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
// Defining site: this inline element was extracted into a reuse
|
|
101
|
+
// snippet — emit the include so one copy of the text survives.
|
|
102
|
+
// (Escape-wise the include directive passes through verbatim:
|
|
103
|
+
// the serializer's escapePreservingMinja treats it as an atom.)
|
|
104
|
+
if (ctx.conref && node.attribs?.id && !node.attribs?.conref && !node.attribs?.conkeyref) {
|
|
105
|
+
const defining = ctx.conref.definingSnippet(node.attribs.id);
|
|
106
|
+
if (defining && inlineSafeSnippet(defining)) {
|
|
107
|
+
pushText(`{% include "${ctx.conref.includePath(defining)}" %}`);
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
// Inline conrefs (<ph conref="…"/>) are the standard DITA reused-text
|
|
112
|
+
// pattern. With a corpus plan the target is spliced back as a minja
|
|
113
|
+
// include; otherwise (or when splicing is unsafe here) the occurrence
|
|
114
|
+
// is real content loss and must be on the ledger.
|
|
115
|
+
if (node.attribs?.conref || node.attribs?.conkeyref) {
|
|
116
|
+
const ref = node.attribs.conref ?? node.attribs.conkeyref;
|
|
117
|
+
const snippet = node.attribs.conref && !node.attribs.conrefend && !node.attribs.conaction
|
|
118
|
+
? ctx.conref?.resolve(node.attribs.conref)
|
|
119
|
+
: undefined;
|
|
120
|
+
if (snippet && inlineSafeSnippet(snippet)) {
|
|
121
|
+
// Local children are the stale preview copy in DITA conref
|
|
122
|
+
// semantics — the include replaces the whole element
|
|
123
|
+
pushText(`{% include "${ctx.conref.includePath(snippet)}" %}`);
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
ctx.note(node.attribs.conref ? "@conref" : "@conkeyref", `<${name}> pulls content from "${ref}" — ${conrefLedgerDetail(node.attribs, snippet, ctx.conref !== undefined)}`);
|
|
127
|
+
}
|
|
128
|
+
// Key-based text reuse (<ph keyref="product-name"/>, <keyword keyref=…>).
|
|
129
|
+
// Authored fallback content always wins — it is the only text that is
|
|
130
|
+
// guaranteed to exist (href-only keys have no text to resolve). Only
|
|
131
|
+
// content-less elements emit the {{ key }} minja variable form.
|
|
132
|
+
if (node.attribs?.keyref && name !== "xref" && name !== "link" && name !== "image") {
|
|
133
|
+
const hasFallback = children.some((c) => isElement(c) || (isText(c) && c.data.trim().length > 0));
|
|
134
|
+
if (!hasFallback) {
|
|
135
|
+
noteOnce(ctx, "@keyref", "content-less keyref emitted as {{ key }} minja variable — resolves only for TEXT keys (keys.yaml entries with text:); href-only keys need manual attention");
|
|
136
|
+
pushText(`{{ ${node.attribs.keyref} }}`);
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
// Fallback content present: note the dropped indirection, then fall
|
|
140
|
+
// through so the element converts normally (term stays italic, …)
|
|
141
|
+
noteOnce(ctx, "@keyref", "keyref with fallback content: authored text kept, key indirection dropped — switch to {{ key }} manually where the key text should win");
|
|
142
|
+
}
|
|
143
|
+
if (TRANSPARENT.has(name)) {
|
|
144
|
+
out.push(...convertInline(children, ctx, formatting));
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
if (CODE_LIKE.has(name)) {
|
|
148
|
+
if (name !== "codeph" && name !== "tt") {
|
|
149
|
+
noteOnce(ctx, `<${name}>`, `rendered as inline code — semantic identity not preserved`);
|
|
150
|
+
}
|
|
151
|
+
out.push({ type: "code", text: collapseWhitespace(textOf(children)).trim() });
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
if (BOLD_LIKE.has(name)) {
|
|
155
|
+
if (name !== "b") {
|
|
156
|
+
noteOnce(ctx, `<${name}>`, `rendered as bold — semantic identity not preserved`);
|
|
157
|
+
}
|
|
158
|
+
out.push(...convertInline(children, ctx, { ...formatting, bold: true }));
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
if (ITALIC_LIKE.has(name)) {
|
|
162
|
+
if (name !== "i") {
|
|
163
|
+
noteOnce(ctx, `<${name}>`, `rendered as italic — semantic identity not preserved`);
|
|
164
|
+
}
|
|
165
|
+
out.push(...convertInline(children, ctx, { ...formatting, italic: true }));
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
if (name === "u") {
|
|
169
|
+
noteOnce(ctx, "<u>", "underline has no markdown equivalent — rendered as plain text");
|
|
170
|
+
out.push(...convertInline(children, ctx, formatting));
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
if (name === "sub" || name === "sup") {
|
|
174
|
+
noteOnce(ctx, `<${name}>`, "sub/superscript rendered as plain text");
|
|
175
|
+
out.push(...convertInline(children, ctx, formatting));
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
if (name === "xref" || name === "link") {
|
|
179
|
+
const href = node.attribs?.href;
|
|
180
|
+
const keyref = node.attribs?.keyref;
|
|
181
|
+
const linkChildren = convertInline(children, ctx, formatting);
|
|
182
|
+
const fallbackText = collapseWhitespace(textOf(children)).trim();
|
|
183
|
+
if (keyref) {
|
|
184
|
+
// Key-based links keep their indirection via the key: scheme
|
|
185
|
+
// (resolution is the build pipeline's job — see topic-map keys)
|
|
186
|
+
out.push({
|
|
187
|
+
type: "link",
|
|
188
|
+
href: `key:${keyref}`,
|
|
189
|
+
children: linkChildren.length > 0 ? linkChildren : [{ type: "text", text: keyref }],
|
|
190
|
+
});
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
if (href) {
|
|
194
|
+
const external = /^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(href);
|
|
195
|
+
out.push({
|
|
196
|
+
type: "link",
|
|
197
|
+
href: external ? href : renameDitaHref(href),
|
|
198
|
+
children: linkChildren.length > 0
|
|
199
|
+
? linkChildren
|
|
200
|
+
: [{ type: "text", text: fallbackText || href }],
|
|
201
|
+
});
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
noteOnce(ctx, `<${name}>`, "xref without href/keyref — emitted as plain text");
|
|
205
|
+
pushText(fallbackText);
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
if (name === "image") {
|
|
209
|
+
const imgHref = node.attribs?.href;
|
|
210
|
+
if (!imgHref) {
|
|
211
|
+
if (node.attribs?.keyref) {
|
|
212
|
+
ctx.note("@keyref", `<image keyref="${node.attribs.keyref}"/> — key-based images cannot be resolved at conversion; insert the image manually`);
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
noteOnce(ctx, "<image>", "image without href dropped");
|
|
216
|
+
}
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
out.push({
|
|
220
|
+
type: "image",
|
|
221
|
+
src: imgHref,
|
|
222
|
+
...(node.attribs?.alt ? { alt: node.attribs.alt } : {}),
|
|
223
|
+
});
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
if (name === "indexterm" || name === "draft-comment" || name === "data") {
|
|
227
|
+
noteOnce(ctx, `<${name}>`, "metadata element dropped from output");
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
// Unknown inline element: keep the text, note the loss
|
|
231
|
+
noteOnce(ctx, `<${name}>`, "unrecognized inline element — text kept, markup dropped");
|
|
232
|
+
out.push(...convertInline(children, ctx, formatting));
|
|
233
|
+
}
|
|
234
|
+
return mergeAdjacentText(out);
|
|
235
|
+
};
|
|
236
|
+
/** Merge neighbouring text spans with identical formatting (recursive calls
|
|
237
|
+
* push whole runs, so pushText's local merging alone is not enough). */
|
|
238
|
+
const mergeAdjacentText = (nodes) => {
|
|
239
|
+
const merged = [];
|
|
240
|
+
for (const node of nodes) {
|
|
241
|
+
const prev = merged[merged.length - 1];
|
|
242
|
+
if (node.type === "text" &&
|
|
243
|
+
prev?.type === "text" &&
|
|
244
|
+
!!prev.bold === !!node.bold &&
|
|
245
|
+
!!prev.italic === !!node.italic &&
|
|
246
|
+
!!prev.strikethrough === !!node.strikethrough) {
|
|
247
|
+
prev.text += node.text;
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
merged.push(node);
|
|
251
|
+
}
|
|
252
|
+
return merged;
|
|
253
|
+
};
|
|
254
|
+
/** Trim leading/trailing whitespace-only fringe from an inline run. */
|
|
255
|
+
export const trimInline = (nodes) => {
|
|
256
|
+
const result = [...nodes];
|
|
257
|
+
while (result.length > 0) {
|
|
258
|
+
const first = result[0];
|
|
259
|
+
if (first.type === "text") {
|
|
260
|
+
first.text = first.text.replace(/^\s+/, "");
|
|
261
|
+
if (first.text === "") {
|
|
262
|
+
result.shift();
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
break;
|
|
267
|
+
}
|
|
268
|
+
while (result.length > 0) {
|
|
269
|
+
const last = result[result.length - 1];
|
|
270
|
+
if (last.type === "text") {
|
|
271
|
+
last.text = last.text.replace(/\s+$/, "");
|
|
272
|
+
if (last.text === "") {
|
|
273
|
+
result.pop();
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
return result;
|
|
280
|
+
};
|
|
281
|
+
//# sourceMappingURL=inline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inline.js","sourceRoot":"","sources":["../src/inline.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,cAAc,EAAiD,MAAM,YAAY,CAAC;AAU3F;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,OAAyB,EAAW,EAAE,CACtE,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,WAAW,KAAK,SAAS,CAAC;AAE1D;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,OAA2C,EAC3C,OAAqC,EACrC,OAAgB,EACR,EAAE;IACV,IAAI,OAAO,EAAE,SAAS,EAAE,CAAC;QACvB,OAAO,2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G,CAAC,GAAG,KAAK,CAAC,CAAC;IAC1B,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzB,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QACxB,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YAC1B,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YAC5C,IAAI,KAAK,CAAC,IAAI,KAAK,EAAE,EAAE,CAAC;gBACtB,MAAM,CAAC,KAAK,EAAE,CAAC;gBACf,SAAS;YACX,CAAC;QACH,CAAC;QACD,MAAM;IACR,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACvC,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YAC1C,IAAI,IAAI,CAAC,IAAI,KAAK,EAAE,EAAE,CAAC;gBACrB,MAAM,CAAC,GAAG,EAAE,CAAC;gBACb,SAAS;YACX,CAAC;QACH,CAAC;QACD,MAAM;IACR,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DitaParseOptions, DitaTopicResult } from "./types.js";
|
|
2
|
+
export interface DitaMarkdownResult extends DitaTopicResult {
|
|
3
|
+
/** Complete dogsbay-md document: frontmatter + body. */
|
|
4
|
+
markdown: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Convert a DITA topic to a complete dogsbay-md document. Frontmatter
|
|
8
|
+
* carries the title, the DITA-derived contentType, and provenance
|
|
9
|
+
* (`dita.id`, original path) for round-trip.
|
|
10
|
+
*/
|
|
11
|
+
export declare function ditaTopicToDogsbayMd(xml: string, options?: DitaParseOptions): DitaMarkdownResult;
|
|
12
|
+
//# sourceMappingURL=markdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAWpE,MAAM,WAAW,kBAAmB,SAAQ,eAAe;IACzD,wDAAwD;IACxD,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,gBAAqB,GAC7B,kBAAkB,CAoDpB"}
|
package/dist/markdown.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { treeToDogsbayMd } from "@dogsbay/format-dogsbay-md";
|
|
2
|
+
import { ditaTopicToTree } from "./parse.js";
|
|
3
|
+
/** DITA topic type → dogsbay contentType frontmatter value. */
|
|
4
|
+
const CONTENT_TYPE_MAP = {
|
|
5
|
+
concept: "concept",
|
|
6
|
+
task: "task",
|
|
7
|
+
reference: "reference",
|
|
8
|
+
glossentry: "glossary",
|
|
9
|
+
topic: "topic",
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Convert a DITA topic to a complete dogsbay-md document. Frontmatter
|
|
13
|
+
* carries the title, the DITA-derived contentType, and provenance
|
|
14
|
+
* (`dita.id`, original path) for round-trip.
|
|
15
|
+
*/
|
|
16
|
+
export function ditaTopicToDogsbayMd(xml, options = {}) {
|
|
17
|
+
const result = ditaTopicToTree(xml, options);
|
|
18
|
+
const frontmatter = {};
|
|
19
|
+
if (result.meta.title)
|
|
20
|
+
frontmatter.title = result.meta.title;
|
|
21
|
+
if (result.meta.ditaType) {
|
|
22
|
+
frontmatter.contentType = CONTENT_TYPE_MAP[result.meta.ditaType] ?? result.meta.ditaType;
|
|
23
|
+
}
|
|
24
|
+
if (result.meta.shortdesc)
|
|
25
|
+
frontmatter.description = result.meta.shortdesc;
|
|
26
|
+
if (result.meta.authors?.length) {
|
|
27
|
+
frontmatter.author = result.meta.authors.length === 1 ? result.meta.authors[0] : result.meta.authors;
|
|
28
|
+
}
|
|
29
|
+
if (result.meta.tags?.length)
|
|
30
|
+
frontmatter.tags = result.meta.tags;
|
|
31
|
+
if (result.meta.categories?.length) {
|
|
32
|
+
// dogsbay frontmatter carries a single category — extras are ledgered,
|
|
33
|
+
// never silently dropped
|
|
34
|
+
frontmatter.category = result.meta.categories[0];
|
|
35
|
+
if (result.meta.categories.length > 1) {
|
|
36
|
+
result.notes.push({
|
|
37
|
+
topicPath: options.topicPath ?? "",
|
|
38
|
+
construct: "<prolog>/<category>",
|
|
39
|
+
detail: `frontmatter carries one category; additional dropped: ${result.meta.categories.slice(1).join(", ")}`,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (result.meta.created)
|
|
44
|
+
frontmatter.created = result.meta.created;
|
|
45
|
+
if (result.meta.revised)
|
|
46
|
+
frontmatter.revised = result.meta.revised;
|
|
47
|
+
const dita = {};
|
|
48
|
+
if (result.meta.id)
|
|
49
|
+
dita.id = result.meta.id;
|
|
50
|
+
if (options.topicPath)
|
|
51
|
+
dita.source = options.topicPath;
|
|
52
|
+
if (Object.keys(dita).length > 0)
|
|
53
|
+
frontmatter.dita = dita;
|
|
54
|
+
// The primary topic's id must exist as an in-page anchor: bare-fragment
|
|
55
|
+
// links (other.md#topicid) are kept by renameDitaHref and target it
|
|
56
|
+
const tree = result.meta.id
|
|
57
|
+
? [
|
|
58
|
+
{
|
|
59
|
+
type: "html",
|
|
60
|
+
html: `<a id="${result.meta.id.replace(/"/g, """)}"></a>`,
|
|
61
|
+
},
|
|
62
|
+
...result.tree,
|
|
63
|
+
]
|
|
64
|
+
: result.tree;
|
|
65
|
+
const markdown = treeToDogsbayMd(tree, {
|
|
66
|
+
frontmatter: Object.keys(frontmatter).length > 0
|
|
67
|
+
? frontmatter
|
|
68
|
+
: undefined,
|
|
69
|
+
});
|
|
70
|
+
return { ...result, markdown: markdown.endsWith("\n") ? markdown : `${markdown}\n` };
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=markdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAG7C,+DAA+D;AAC/D,MAAM,gBAAgB,GAA2B;IAC/C,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,MAAM;IACZ,SAAS,EAAE,WAAW;IACtB,UAAU,EAAE,UAAU;IACtB,KAAK,EAAE,OAAO;CACf,CAAC;AAOF;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAClC,GAAW,EACX,UAA4B,EAAE;IAE9B,MAAM,MAAM,GAAG,eAAe,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAE7C,MAAM,WAAW,GAA4B,EAAE,CAAC;IAChD,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK;QAAE,WAAW,CAAC,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;IAC7D,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACzB,WAAW,CAAC,WAAW,GAAG,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;IAC3F,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS;QAAE,WAAW,CAAC,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;IAC3E,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MA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IAAI,CAAC,EAAE,CAAC;IAC7C,IAAI,OAAO,CAAC,SAAS;QAAE,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IACvD,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC;QAAE,WAAW,CAAC,IAAI,GAAG,IAAI,CAAC;IAE1D,wEAAwE;IACxE,oEAAoE;IACpE,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE;QACzB,CAAC,CAAC;YACE;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,UAAU,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,QAAQ;aAC/D;YACD,GAAG,MAAM,CAAC,IAAI;SACf;QACH,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC;IAEhB,MAAM,QAAQ,GAAG,eAAe,CAAC,IAAI,EAAE;QACrC,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,GAAG,CAAC;YAC9C,CAAC,CAAE,WAAqC;YACxC,CAAC,CAAC,SAAS;KACd,CAAC,CAAC;IAEH,OAAO,EAAE,GAAG,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,IAAI,EAAE,CAAC;AACvF,CAAC"}
|
package/dist/parse.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type DitaParseOptions, type DitaTopicResult } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Convert one DITA topic document to a TreeNode[] block tree plus topic
|
|
4
|
+
* metadata and a conversion-note ledger. Never throws on content problems.
|
|
5
|
+
*
|
|
6
|
+
* The primary topic's <title> becomes `meta.title` (page-level, not a
|
|
7
|
+
* block); <shortdesc> is both `meta.shortdesc` and the first paragraph.
|
|
8
|
+
* Additional topics — nested inside the primary or siblings under a
|
|
9
|
+
* composite (<dita>) wrapper — convert inline as heading-anchored sections,
|
|
10
|
+
* so multi-topic (chunked) files lose nothing.
|
|
11
|
+
*/
|
|
12
|
+
export declare function ditaTopicToTree(xml: string, options?: DitaParseOptions): DitaTopicResult;
|
|
13
|
+
//# sourceMappingURL=parse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,eAAe,EAGrB,MAAM,YAAY,CAAC;AAuLpB;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,GAAG,eAAe,CA8H5F"}
|