From d812cf3134cf2a186a5f10a1283d0e2649b7755e Mon Sep 17 00:00:00 2001 From: Rowan Cockett Date: Fri, 10 Nov 2023 08:47:34 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=97=20Link=20copy=20should=20not=20inc?= =?UTF-8?q?lude=20zero-width=20space=20(#260)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The zero-width space is used for formatting. This is now turned into a `` tag, which doesn't copy to clipboard. --- .changeset/plenty-bears-applaud.md | 5 +++++ packages/myst-to-react/src/basic.tsx | 17 ++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 .changeset/plenty-bears-applaud.md 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}