Skip to content

fix: use Unicode ZWSP instead of HTML entity in markdown content#192

Open
mstrofnone wants to merge 1 commit into
PrimalHQ:mainfrom
mstrofnone:fix/zwsp-html-entity-in-markdown
Open

fix: use Unicode ZWSP instead of HTML entity in markdown content#192
mstrofnone wants to merge 1 commit into
PrimalHQ:mainfrom
mstrofnone:fix/zwsp-html-entity-in-markdown

Conversation

@mstrofnone
Copy link
Copy Markdown

Problem

The email regex handler in MarkdownSlice.tsx and MarkdownEditor.tsx inserts a zero-width space before @ to prevent Milkdown from treating email-like patterns as mentions. However, it uses the HTML entity ​ which gets inserted into the markdown source text passed to Milkdown's insert().

Since insert() processes markdown (not HTML), the entity is never interpreted — it passes through as literal text and renders as visible ​ characters in articles.

Example: https://primal.net/a/naddr1qvzqqqr4gupzqscctm0vke6cj2pykx3h54lnusrlhh3wxmfeqrguznwx0fwnutd8sqq3kuctdv43k76tw945kuar9vaexzarfdahz6ctdv46xs7tnwskkwatfv3jsz0753t

The raw event content (verified via relay) contains no ​ — it's injected client-side by the regex replacement.

Fix

Replace the HTML entity string ​ with the actual Unicode zero-width space character (\u200B), which is invisible in both markdown source and HTML rendering.

Files Changed

  • src/components/PrimalMarkdown/MarkdownSlice.tsx (read-only article view)
  • src/components/PrimalMarkdown/MarkdownEditor.tsx (editor)

The email regex handler inserts a zero-width space before '@' to prevent
Milkdown from treating email addresses as mentions. However, it uses the
HTML entity '​' which gets inserted into markdown source text.

Since Milkdown's insert() processes markdown (not HTML), the entity is
not interpreted — it passes through as literal text and appears as
visible '​' in rendered articles.

Replace with the actual Unicode zero-width space character (U+200B)
which is invisible in both markdown and HTML rendering.

Affects both MarkdownSlice.tsx (read-only view) and MarkdownEditor.tsx.
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