Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔗 Link copy should not include zero-width space #260

Merged
merged 2 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading