@handsupmin/gc-tree 0.7.12 → 0.7.13
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/src/markdown.js +14 -1
- package/package.json +1 -1
package/dist/src/markdown.js
CHANGED
|
@@ -71,9 +71,22 @@ export function ensureSummary(summary) {
|
|
|
71
71
|
}
|
|
72
72
|
return trimmed;
|
|
73
73
|
}
|
|
74
|
+
function normalizeBody(raw, title) {
|
|
75
|
+
let s = raw.trim();
|
|
76
|
+
// Strip leading "# <title>" line (already rendered at top level)
|
|
77
|
+
const titleLine = `# ${title.trim()}`;
|
|
78
|
+
if (s.startsWith(titleLine))
|
|
79
|
+
s = s.slice(titleLine.length).trimStart();
|
|
80
|
+
// Strip leading "## Summary" block (already rendered at top level)
|
|
81
|
+
if (s.startsWith('## Summary')) {
|
|
82
|
+
const next = s.match(/\n(?=## )/);
|
|
83
|
+
s = next ? s.slice(next.index).trimStart() : '';
|
|
84
|
+
}
|
|
85
|
+
return s;
|
|
86
|
+
}
|
|
74
87
|
export function renderDocMarkdown(doc) {
|
|
75
88
|
const summary = ensureSummary(doc.summary);
|
|
76
|
-
const body = String(doc.body || '').
|
|
89
|
+
const body = normalizeBody(String(doc.body || ''), doc.title);
|
|
77
90
|
const normalizedIndexEntries = [...new Set([
|
|
78
91
|
...(doc.indexLabel?.trim() ? [doc.indexLabel.trim()] : []),
|
|
79
92
|
...(doc.indexEntries || []).map((entry) => String(entry || '').trim()).filter(Boolean),
|