Skip to content

Commit 9072e10

Browse files
committed
fix(dwkim): strip hyperlink URLs from markdown in TUI
TUI에서 클릭 불가능한 하이퍼링크 URL을 제거하고 텍스트만 유지. [블로그](url) → 블로그. 인라인 인용 [이력서] 패턴은 유지.
1 parent a6bbbbf commit 9072e10

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

packages/dwkim/src/ui/MarkdownText.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ interface Props {
1515
// hex 색상을 chalk 함수로 변환
1616
const hex = (color: string) => chalk.hex(color)
1717

18+
// TUI에서 하이퍼링크는 클릭 불가 → [text](url) 에서 URL 제거, 텍스트만 유지
19+
const HYPERLINK_PATTERN = /\[([^\]]+)\]\([^)]+\)/g
20+
1821
// 인라인 인용 패턴: [이력서], [100문100답], [블로그: 제목], [지식: 제목] 등
1922
const CITATION_PATTERN = /\[(|100100|:\s*[^\]]+|[^\]]{2,30})\]/g
2023
const citationStyle = chalk.hex(theme.muted).dim
@@ -36,9 +39,7 @@ marked.use(
3639
em: chalk.italic,
3740
codespan: hex(theme.lavender),
3841
del: hex(theme.muted).strikethrough,
39-
link: hex(theme.info),
40-
href: hex(theme.info).underline,
41-
// 옵션
42+
// 옵션 (link/href 불필요: HYPERLINK_PATTERN으로 사전 제거)
4243
showSectionPrefix: false,
4344
reflowText: true,
4445
width: 80,
@@ -64,8 +65,10 @@ export function MarkdownText({ children, color }: Props) {
6465
if (!children) return ''
6566

6667
try {
68+
// TUI: 하이퍼링크 URL 제거 (클릭 불가이므로 텍스트만 유지)
69+
const stripped = children.replace(HYPERLINK_PATTERN, '$1')
6770
// marked-terminal은 ANSI escape code가 포함된 문자열을 반환
68-
let result = marked.parse(children, { async: false }) as string
71+
let result = marked.parse(stripped, { async: false }) as string
6972
// 끝의 불필요한 줄바꿈 제거
7073
result = result.replace(/\n+$/, '')
7174
// 인라인 인용 스타일링: [이력서] → dim muted 색상

0 commit comments

Comments
 (0)