Skip to content

Commit

Permalink
🔗 Link copy should not include zero-width space (#260)
Browse files Browse the repository at this point in the history
The zero-width space is used for formatting.
This is now turned into a `<wbr>` tag, which doesn't copy to clipboard.
  • Loading branch information
rowanc1 authored Nov 10, 2023
1 parent c4f154d commit d812cf3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/plenty-bears-applaud.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'myst-to-react': patch
---

Improve link URL copying
17 changes: 16 additions & 1 deletion packages/myst-to-react/src/basic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,22 @@ type BasicNodeRenderers = {

const BASIC_RENDERERS: BasicNodeRenderers = {
text({ node }) {
return <>{node.value}</>;
// Change zero-width space into `<wbr>` which is better for copying
// These are used in links, and potentially other long words
if (!node.value?.includes('​')) {
return <>{node.value}</>;
}
const text = node.value.split('​');
return (
<>
{text.map((v, i) => (
<>
{v}
{i < text.length - 1 && <wbr />}
</>
))}
</>
);
},
span({ node }) {
// style={node.style}
Expand Down

0 comments on commit d812cf3

Please sign in to comment.