Skip to content

Fix WordPress import crash on posts with YAML-special markdown#234

Merged
oandregal merged 1 commit into
trunkfrom
focused-bartik-3221ff
May 21, 2026
Merged

Fix WordPress import crash on posts with YAML-special markdown#234
oandregal merged 1 commit into
trunkfrom
focused-bartik-3221ff

Conversation

@oandregal
Copy link
Copy Markdown
Contributor

Summary

  • WordPress imports crash silently when a post's markdown body contains YAML-special characters (*TL; alias syntax, leading - list items, unquoted colons). gray-matter's stringify re-parses the body through its YAML engine, which throws a YAMLException that escapes the IPC handler — the modal gets no response and silently resets.
  • Replace matter.stringify with a stringifyFrontmatter helper that uses js-yaml.dump() for the frontmatter data only, then concatenates the body as a raw string — YAML never touches the markdown.
  • Move the serialization call inside the existing try-catch so a single bad post gets skipped instead of killing the entire import loop.

Test plan

  • Import a WordPress.com site that has posts with *TL;DR* or **TL; DR:** in the body — should import all posts without crashing
  • Verify imported markdown files have correct frontmatter (title, wp_post_id, wp_categories, etc.)
  • Verify the import note at sources/notes/imported-from-wordpress.md is written correctly
  • Run npm run test:unit — all 503 tests pass

🤖 Generated with Claude Code

gray-matter's stringify re-parses the body through its YAML engine,
which throws on markdown containing YAML alias syntax (*TL;), leading
dashes, and other special chars. The unhandled exception killed the
entire import handler — the IPC call never returned, so the modal
silently reset with no error message.

Replace matter.stringify with a stringifyFrontmatter helper that uses
js-yaml to serialize only the frontmatter data, then concatenates the
body as a raw string. Move the call inside the existing try-catch so
a single bad post gets skipped instead of crashing the whole import.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 21, 2026 14:41
@oandregal oandregal merged commit 1409e6e into trunk May 21, 2026
1 check failed
@oandregal oandregal deleted the focused-bartik-3221ff branch May 21, 2026 14:41
@oandregal oandregal review requested due to automatic review settings May 21, 2026 15:03
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