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

Android anchor markdown format 40564 #42147

Merged
4 changes: 3 additions & 1 deletion src/pages/home/report/ContextMenu/ContextMenuActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ function setClipboardMessage(content: string) {
if (!Clipboard.canSetHtml()) {
Clipboard.setString(parser.htmlToMarkdown(content));
} else {
const plainText = parser.htmlToText(content);
const anchorRegex = /<a\s+(?:[^>]*?\s+)?href=['"](.*?)['"]/;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we reuse this regex?

const regex = /<a\s+(?:[^>]*?\s+)?href="([^"]*)"/gi;

const isAnchorTag = anchorRegex.test(content);
const plainText = isAnchorTag ? parser.htmlToMarkdown(content) : parser.htmlToText(content);
Clipboard.setHtml(content, plainText);
}
}
Expand Down
Loading