💄 add chapter titles to export

This commit is contained in:
2026-05-23 04:10:16 +10:00
parent 3b769f03bf
commit 76a8a934cd

View File

@@ -307,9 +307,11 @@ export function registerIpcHandlers(): void {
needsPageBreak = false needsPageBreak = false
} }
const chapterTitle = doc.relativePath.split('/').pop() ?? doc.relativePath
const safeChapterTitle = chapterTitle.replace(/&/g, '&amp;').replace(/</g, '&lt;')
const contentHtml = await marked(normalize(doc.content)) const contentHtml = await marked(normalize(doc.content))
const cls = needsPageBreak ? 'page-break chapter' : 'chapter' const cls = needsPageBreak ? 'page-break chapter' : 'chapter'
bodyHtml += `<div class="${cls}">${contentHtml}</div>` bodyHtml += `<div class="${cls}"><h2>${safeChapterTitle}</h2>${contentHtml}</div>`
needsPageBreak = true needsPageBreak = true
} }