Skip to content

fix: rewrite SVG asset references to PNG after raster-embedded conversion - #242

Open
mrbobbytables wants to merge 1 commit into
mainfrom
fix/rewrite-svg-to-png-asset-ref
Open

mrbobbytables wants to merge 1 commit into
mainfrom
fix/rewrite-svg-to-png-asset-ref

Conversation

@mrbobbytables

Copy link
Copy Markdown
Member

Summary

scripts/import-architectures.mjs converts raster-embedded SVGs to PNG via rsvg-convert, but it left the architecture record's assets list (and any inline markdown image references) pointing at the original .svg path, which no longer exists on disk once converted. This caused npm run validate:architectures to fail in the scheduled Import reference architectures workflow with:

[error] swisscom-cloud-native-telco: missing asset /img/architectures/swisscom-cloud-native-telco/swisscom-cloud-native-telco-automation-architecture-overview.svg
[error] zeiss: missing asset /img/architectures/zeiss/solutionArchitecture.svg

Fix

  • Build record.assets from the actual post-sanitization asset directory listing rather than the pre-conversion source file listing, so the catalog references the files that really exist on disk.
  • sanitizeArchitectureAssets now returns a rename map (old-relative-path.svg -> new-relative-path.png) for every SVG it converts.
  • cleanMarkdown uses that rename map to rewrite any inline ![alt](images/name.svg) references in the imported architecture body to the .png path that was actually written, so the generated docs page doesn't link to a missing image either.

Testing

  • npm run test:unit (55/55 passing)
  • npm run check
  • Manually exercised the extracted conversion/rename logic with a stubbed rsvg-convert to confirm a converted SVG's markdown reference and directory listing are rewritten to .png.

Fixes #218

— hive: backend=copilot

🐝 Hive Agent: contributor | SHA: 74ff41f

…sion

import-architectures.mjs converts raster-embedded SVGs to PNG via
rsvg-convert, but previously left the architecture record's assets
list (and any inline markdown image references) pointing at the
original .svg path, which no longer exists on disk. This caused
validate:architectures to fail with 'missing asset ...svg' for
architectures such as swisscom-cloud-native-telco and zeiss.

Build record.assets from the actual post-sanitization asset
directory listing instead of the pre-conversion source listing, and
have sanitizeArchitectureAssets return a rename map so cleanMarkdown
can rewrite any inline .svg image references in the imported body to
the .png path that was actually written.

Fixes #218

Signed-off-by: mrbobbytables <mrbobbytables@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant