Repository navigation
fix(mcp): keep text in angle brackets when saving Markdown - #849
Conversation
BlockNote's Markdown parser drops raw HTML, so text such as `<store>` or the `<string>` in `Promise<string>` was deleted from tasks, documents and comments saved through MCP. No error was returned. markdownToBlocknote now parses the Markdown once with HTML turned off to find each `<` that is plain text, and replaces it with `<x/><`. Code and `<https://...>` links are left as they are. BlockNote drops the empty tag, which stops a bare URL before the `<`; without it, `https://example.com/<id>` was saved as `https://example.com/<id>`. HTML tags and comments now show as typed. Dropping only comments would also delete text after one on the same line, and everything after an unclosed one. Fixes Paca-AI#844 Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
✅ No new issues found.
Approach: sound — one preprocessing step at the markdownToBlocknote choke point, so every MCP write path (tasks, documents, comments, push) is covered, with no new dependencies and no changes to BlockNote.
Reviewed changes
keepAngleBracketspreprocessor — parses the Markdown once with micromark'shtmlFlow/htmlTextdisabled and rewrites each text-node<to<x/><; code, autolinks and link syntax fall outside text-node ranges and are left alone.markdownToBlocknotewiring — the preprocessed Markdown is now what BlockNote parses.- Tests — seven angle-bracket cases plus code/autolink/BOM guards; I confirmed seven of them fail when the
keepAngleBrackets(...)call is bypassed. - CHANGELOG —
[Unreleased] / Fixedentry records the agreed HTML-as-text behavior change.
ℹ️ The same text loss remains on the web Markdown-upload path
Uploading a .md file goes through apps/web/src/lib/markdown-import.ts, which calls the same tryParseMarkdownToBlocks with the same @blocknote/core version, so a file containing <store> still loses that text. This is outside this MCP-scoped PR and is not a change request here, but it is the same root cause and worth a follow-up issue.
Technical details
# Same angle-bracket loss in web Markdown import
## Affected sites
- `apps/web/src/lib/markdown-import.ts:44` — `markdownToDocument` parses uploaded Markdown with `tryParseMarkdownToBlocks` directly.
- `apps/web/src/lib/file-uploads.ts:112` — calls `importMarkdownFile` for `.md` uploads.
## Required outcome
- Angle-bracket text survives a Markdown file upload into Documentation the same way it now does through MCP.
- Suggested approach: move `keepAngleBrackets` into a helper both apps can import, or mirror it in `markdown-import.ts`.deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
pikann
left a comment
There was a problem hiding this comment.
LGTM! Thank you for the contribution! 🚀

Summary
Fixes #844.
Text in angle brackets, such as
<store>or the<string>inPromise<string>, was deleted without an error when tasks, documents or comments were saved through MCP. BlockNote's Markdown parser drops raw HTML.markdownToBlocknotenow parses the Markdown once with HTML turned off to find each unescaped<in normal text, then replaces it with<x/><before BlockNote reads it:<back into<.<x/>tag, but the tag makes a plain URL stop before the<. With<alone,https://example.com/orders/<id>was saved ashttps://example.com/orders/<id>.<https://...>links are left as they are. There are no new dependencies.Behaviour change
HTML tags and comments now show as typed. For example,
line<br>twowas saved aslinetwoand is now kept.Showing comments as text was agreed in #844. Dropping only comments would still lose other text:
<!-- note --> Keep this sentence.is saved empty, and an unclosed<!--can drop the rest of the document.Known limits
<in a plain URL still loses text, for examplehttps://example.com/\<id>.Testing
<https://...>links still work, including a link after a byte order mark.bun run lint,bun run buildandbun run testpass inapps/mcp(1,331 tests).<alone.I used Claude to help write and test this change.
Type of Change
Checklist
apps/mcp/CHANGELOG.md).🤖 Generated with Claude Code