summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/utils/InlineMarkdownRenderer.tsx
diff options
context:
space:
mode:
authorfuyou <[email protected]>2025-08-18 13:26:34 +0800
committerGitHub <[email protected]>2025-08-18 05:26:34 +0000
commit7b03a64b8501a736af8e605f399922a14b8feebb (patch)
treebc2c6fccec9b2d66deaa5a09e5f5756b1f45c318 /packages/cli/src/ui/utils/InlineMarkdownRenderer.tsx
parent133f0230c3d347a1d02c5babc3f1a301622c4f67 (diff)
Fix URL truncation in CLI display components #5902 (#5925)
Diffstat (limited to 'packages/cli/src/ui/utils/InlineMarkdownRenderer.tsx')
-rw-r--r--packages/cli/src/ui/utils/InlineMarkdownRenderer.tsx13
1 files changed, 12 insertions, 1 deletions
diff --git a/packages/cli/src/ui/utils/InlineMarkdownRenderer.tsx b/packages/cli/src/ui/utils/InlineMarkdownRenderer.tsx
index ff8d6257..4c05a28f 100644
--- a/packages/cli/src/ui/utils/InlineMarkdownRenderer.tsx
+++ b/packages/cli/src/ui/utils/InlineMarkdownRenderer.tsx
@@ -22,10 +22,15 @@ interface RenderInlineProps {
}
const RenderInlineInternal: React.FC<RenderInlineProps> = ({ text }) => {
+ // Early return for plain text without markdown or URLs
+ if (!/[*_~`<[https?:]/.test(text)) {
+ return <Text>{text}</Text>;
+ }
+
const nodes: React.ReactNode[] = [];
let lastIndex = 0;
const inlineRegex =
- /(\*\*.*?\*\*|\*.*?\*|_.*?_|~~.*?~~|\[.*?\]\(.*?\)|`+.+?`+|<u>.*?<\/u>)/g;
+ /(\*\*.*?\*\*|\*.*?\*|_.*?_|~~.*?~~|\[.*?\]\(.*?\)|`+.+?`+|<u>.*?<\/u>|https?:\/\/\S+)/g;
let match;
while ((match = inlineRegex.exec(text)) !== null) {
@@ -126,6 +131,12 @@ const RenderInlineInternal: React.FC<RenderInlineProps> = ({ text }) => {
)}
</Text>
);
+ } else if (fullMatch.match(/^https?:\/\//)) {
+ renderedNode = (
+ <Text key={key} color={Colors.AccentBlue}>
+ {fullMatch}
+ </Text>
+ );
}
} catch (e) {
console.error('Error parsing inline markdown part:', fullMatch, e);