Skip to content

fix: place Markdown/HTML attachment assets under target folder#60

Merged
rogerdigital merged 1 commit into
mainfrom
fix/markdown-html-assets-folder-location
Jun 24, 2026
Merged

fix: place Markdown/HTML attachment assets under target folder#60
rogerdigital merged 1 commit into
mainfrom
fix/markdown-html-assets-folder-location

Conversation

@rogerdigital

Copy link
Copy Markdown
Owner

Problem

When exporting a folder as Markdown or HTML, a stray extra assets folder appeared at the export root, instead of (only) under the target folder — inconsistent with PDF/DOCX.

Root Cause

Attachments were copied twice:

  • ExportRunner Step 6 (centralized) copies into <assetsRoot>/assets — the target folder (e.g. exports/Publio/assets), consistent with PDF/DOCX
  • renderMarkdownBundle and renderHtmlDocument self-copied into plan.outputRoot/assets — the export root (e.g. exports/assets)

For a folder source these paths differ (assetsRoot = outputRoot/outputFolderName), so both copies were written and the stray folder appeared. Single-file exports happened to match, so the bug was hidden.

PDF/DOCX never had the issue — they don't self-copy (PDF inlines as dataURI, DOCX embeds in the file).

Fix

Removed the self-copying logic (ensureFolder(outputRoot/assets) + the copyBinaryFile loop) from renderMarkdownBundle and renderHtmlDocument. Attachments are now copied only by ExportRunner Step 6 — landing in the target folder's assets dir, matching PDF/DOCX, with cross-file deduplication.

Tests

  • 160/160 pass
  • html-document: asserts renderer no longer creates its own assets folder or calls copyBinaryFile
  • ExportRunner: asserts attachments land in <targetFolder>/assets, not the export root

When exporting a folder as Markdown or HTML, attachments were copied
twice: once by ExportRunner Step 6 into the target folder's assets dir
(<assetsRoot>/assets, consistent with PDF/DOCX), and again by the format
renderers into plan.outputRoot/assets (the export root). For a folder
source these differ (assetsRoot = outputRoot/outputFolderName), so a
stray extra 'assets' folder appeared at the export root.

Remove the self-copying logic from renderMarkdownBundle and
renderHtmlDocument. Attachments are now copied only by ExportRunner Step
6, landing in the target folder's assets dir — matching PDF/DOCX and
deduplicating across files.

Tests:
- html-document: assert the renderer no longer creates its own assets
  folder or calls copyBinaryFile
- ExportRunner: assert attachments land in <targetFolder>/assets, not
  the export root
@rogerdigital rogerdigital merged commit c898371 into main Jun 24, 2026
1 check passed
@rogerdigital rogerdigital deleted the fix/markdown-html-assets-folder-location branch June 24, 2026 14:19
@rogerdigital rogerdigital mentioned this pull request Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant