diff --git a/.changeset/plenty-bears-applaud.md b/.changeset/plenty-bears-applaud.md new file mode 100644 index 000000000..b6c2fa35b --- /dev/null +++ b/.changeset/plenty-bears-applaud.md @@ -0,0 +1,5 @@ +--- +'myst-to-react': patch +--- + +Improve link URL copying diff --git a/packages/myst-to-react/src/basic.tsx b/packages/myst-to-react/src/basic.tsx index 60140b585..500f25ed9 100644 --- a/packages/myst-to-react/src/basic.tsx +++ b/packages/myst-to-react/src/basic.tsx @@ -81,7 +81,22 @@ type BasicNodeRenderers = { const BASIC_RENDERERS: BasicNodeRenderers = { text({ node }) { - return <>{node.value}; + // Change zero-width space into `` 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 && } + + ))} + + ); }, span({ node }) { // style={node.style}