Skip to content

fix(mcp): keep text in angle brackets when saving Markdown - #849

Merged
pikann merged 1 commit into
Paca-AI:masterfrom
khushvir:fix/mcp-angle-brackets
Dec 2, 2026
Merged

pikann merged 1 commit into
Paca-AI:masterfrom
khushvir:fix/mcp-angle-brackets

Conversation

@khushvir

@khushvir khushvir commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #844.

Text in angle brackets, such as <store> or the <string> in Promise<string>, was deleted without an error when tasks, documents or comments were saved through MCP. BlockNote's Markdown parser drops raw HTML.

markdownToBlocknote now parses the Markdown once with HTML turned off to find each unescaped < in normal text, then replaces it with <x/>&lt; before BlockNote reads it:

  • BlockNote turns &lt; back into <.
  • BlockNote drops the empty <x/> tag, but the tag makes a plain URL stop before the &lt;. With &lt; alone, https://example.com/orders/<id> was saved as https://example.com/orders/&lt;id>.
  • Code and <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>two was saved as linetwo and 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

  • A backslash right before < in a plain URL still loses text, for example https://example.com/\<id>.
  • Inline code that spans lines can still lose text if a later line starts with HTML.

Testing

  • There are 9 new tests. 7 of them fail without the fix. The other 2 check that code and <https://...> links still work, including a link after a byte order mark.
  • bun run lint, bun run build and bun run test pass in apps/mcp (1,331 tests).
  • I compared the result with a copy of BlockNote's Markdown steps with HTML turned off, on 5,000 random inputs. Ignoring spaces, the text matched on 4,990, compared with 4,671 using &lt; alone.
  • I haven't tested this in a running Paca.

I used Claude to help write and test this change.

Type of Change

  • Other: bug fix

Checklist

  • The change is focused and scoped.
  • Related documentation is updated (apps/mcp/CHANGELOG.md).
  • New structure or direction is explained clearly.
  • I avoided unnecessary detail or premature abstraction.

🤖 Generated with Claude Code

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/>&lt;`.
Code and `<https://...>` links are left as they are. BlockNote drops
the empty tag, which stops a bare URL before the `&lt;`; without it,
`https://example.com/<id>` was saved as `https://example.com/&lt;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]>

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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

  • keepAngleBrackets preprocessor — parses the Markdown once with micromark's htmlFlow/htmlText disabled and rewrites each text-node < to <x/>&lt;; code, autolinks and link syntax fall outside text-node ranges and are left alone.
  • markdownToBlocknote wiring — 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] / Fixed entry 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`.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

@pikann pikann left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you for the contribution! 🚀

@pikann
pikann merged commit 51047ea into Paca-AI:master Dec 2, 2026
2 checks passed
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.

[Bug] MCP: text in angle brackets is silently deleted from tasks, docs and comments

2 participants