Skip to content

Keep paragraph text in saved Markdown and in the newsletter text part - #1

Merged
arjunpredev merged 1 commit into
mainfrom
fix/markdown-paragraphs-text-part
Oct 23, 2026
Merged

arjunpredev merged 1 commit into
mainfrom
fix/markdown-paragraphs-text-part

Conversation

@arjunpredev

Copy link
Copy Markdown
Contributor

What broke

MarkdownImages (the extension that opens Markdown images as image cards) registers under the paragraph Markdown token so its parser runs first. @tiptap/markdown looks up a node's writer through the parse registry first too, so it asked MarkdownImages how to write paragraphs. It had no renderMarkdown, so every paragraph, list item and table cell saved as an empty string in the post's Markdown copy.

The newsletter's text/plain part is built from that copy (plainBody(post.markdown)), so a post saved from the editor mailed a text part with only headings, image alt text and empty bullets, next to a full HTML part.

Fix

  • MarkdownImages.renderMarkdown writes paragraphs the way the paragraph extension does (children, and   for a second empty paragraph in a row).
  • newsletterEmail builds the text part from the Markdown copy only when it holds at least 80% of the HTML body's words; otherwise from the HTML body. Posts saved before this fix send their full text without a re-save.
  • plainBody writes HTML lists as - item lines and tables as one a | b line per row, with blank lines between blocks.

Checked

  • Round trip through the editor's extensions (Markdown to document to Markdown): before, paragraphs, bullets and table cells came back empty; after, all text is kept.
  • The text part for an affected post: 1.5 KB before (headings and alt text), 7.6 KB after with every paragraph, bullet and table row.
  • bun run typecheck, admin build, leak guard.

🤖 Generated with Claude Code

The image-card extension holds the paragraph Markdown token, so @tiptap/markdown
also asked it how to write paragraphs. It had no writer, so every paragraph
(and every list item and table cell) saved as an empty string in the post's
Markdown copy. The newsletter's text/plain part is built from that copy, so
posts saved from the editor mailed a text part with headings and image alt
text only.

- MarkdownImages writes paragraphs the way the paragraph extension does.
- The newsletter text part falls back to the HTML body when the Markdown copy
  holds clearly fewer words, so posts saved before this fix send their full text.
- plainBody writes HTML lists and tables as one line per item and per row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@arjunpredev
arjunpredev merged commit f49cf1f into main Oct 23, 2026
1 check passed
@arjunpredev
arjunpredev deleted the fix/markdown-paragraphs-text-part branch October 23, 2026 16:41
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