fix: use Unicode ZWSP instead of HTML entity in markdown content#192
Open
mstrofnone wants to merge 1 commit into
Open
fix: use Unicode ZWSP instead of HTML entity in markdown content#192mstrofnone wants to merge 1 commit into
mstrofnone wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The email regex handler in
MarkdownSlice.tsxandMarkdownEditor.tsxinserts 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'sinsert().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)