mirror of
https://github.com/paperclipai/paperclip
synced 2026-04-25 17:25:15 +02:00
Avoid duplicate markdown link icons
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -325,6 +325,7 @@ describe("MarkdownBody", () => {
|
||||
// icon can never be orphaned on the previous line from the URL text.
|
||||
expect(html).toMatch(/<span style="white-space:nowrap">.*lucide-github.*?<\/svg>h<\/span>/);
|
||||
expect(html).toContain("ttps://github.com/paperclipai/paperclip/pull/4099");
|
||||
expect(html).not.toContain("lucide-external-link");
|
||||
});
|
||||
|
||||
it("prefixes GitHub autolinks with the GitHub icon", () => {
|
||||
|
||||
@@ -140,6 +140,8 @@ function renderLinkBody(
|
||||
): ReactNode {
|
||||
if (!leadingIcon && !trailingIcon) return children;
|
||||
|
||||
// React-markdown can pass arrays/elements for styled link text; the nowrap
|
||||
// splitting below is intentionally limited to plain text links.
|
||||
if (typeof children === "string" && children.length > 0) {
|
||||
if (children.length === 1) {
|
||||
return (
|
||||
@@ -332,7 +334,7 @@ export function MarkdownBody({
|
||||
const leadingIcon = isGitHubLink ? (
|
||||
<Github aria-hidden="true" className="mr-1 inline h-3.5 w-3.5 align-[-0.125em]" />
|
||||
) : null;
|
||||
const trailingIcon = isExternal ? (
|
||||
const trailingIcon = isExternal && !isGitHubLink ? (
|
||||
<ExternalLink aria-hidden="true" className="ml-1 inline h-3 w-3 align-[-0.125em]" />
|
||||
) : null;
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user