Skip to content

Commit 3d0bce1

Browse files
shobmanclaude
andcommitted
Strip redundant header block from page body
Remove the first H1 heading and **Key:** Value metadata lines from the top of each markdown file before converting to HTML. These are already surfaced in the Confluence page title and Page Properties macro — rendering them in the body was redundant. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a5ee46a commit 3d0bce1

1 file changed

Lines changed: 30 additions & 6 deletions

File tree

src/connectors/confluence/publish.js

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -304,21 +304,45 @@ marked.use({
304304
// Page body assembly
305305
// ---------------------------------------------------------------------------
306306

307-
function buildPageBody(markdown, meta) {
308-
let html = marked.parse(markdown);
307+
/** Strip the header block that the connector already surfaces in Page Properties. */
308+
function stripHeader(markdown) {
309+
const lines = markdown.split("\n");
310+
let i = 0;
311+
312+
// Skip leading blank lines
313+
while (i < lines.length && lines[i].trim() === "") i++;
314+
315+
// Skip the first H1 heading
316+
if (i < lines.length && lines[i].startsWith("# ")) i++;
317+
318+
// Skip blank lines and **Key:** Value metadata lines
319+
while (i < lines.length) {
320+
const line = lines[i].trim();
321+
if (line === "") { i++; continue; }
322+
if (/^\*\*\w[\w\s]*:\*\*/.test(line)) { i++; continue; }
323+
break;
324+
}
325+
326+
return lines.slice(i).join("\n");
327+
}
328+
329+
function convertMarkdown(markdown) {
330+
let html = marked.parse(stripHeader(markdown));
309331
html = rewriteLinks(html);
310332
html = rewritePanels(html);
311333
html = rewriteExpand(html);
334+
return html;
335+
}
336+
337+
function buildPageBody(markdown, meta) {
338+
const html = convertMarkdown(markdown);
312339
const props = pagePropertiesMacro(meta);
313340
return props ? `${props}\n${html}` : html;
314341
}
315342

316343
/** Build a feature page: properties → Stories section → content. */
317344
function buildFeaturePageBody(markdown, meta) {
318-
let html = marked.parse(markdown);
319-
html = rewriteLinks(html);
320-
html = rewritePanels(html);
321-
html = rewriteExpand(html);
345+
const html = convertMarkdown(markdown);
322346
const props = pagePropertiesMacro(meta);
323347
const parts = [];
324348
if (props) parts.push(props);

0 commit comments

Comments
 (0)