@oh-my-pi/pi-tui 18.1.8 → 18.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [18.1.9] - 2026-09-04
6
+
7
+ ### Added
8
+
9
+ - Added Markdown hyperlink target resolution while preserving the displayed URL text.
10
+
5
11
  ## [18.1.6] - 2026-09-03
6
12
 
7
13
  ### Fixed
@@ -54,6 +54,8 @@ export interface HighlightStreamSession {
54
54
  /** Highlight the next chunk and advance parser state. */
55
55
  push(chunk: string): string;
56
56
  }
57
+ /** Collect distinct hyperlink destinations using the renderer's Markdown grammar, excluding images and code. */
58
+ export declare function getMarkdownLinkUrls(text: string): string[];
57
59
  /**
58
60
  * Theme functions for markdown elements.
59
61
  * Each function takes text and returns styled text with ANSI codes.
@@ -62,6 +64,8 @@ export interface MarkdownTheme {
62
64
  heading: (text: string) => string;
63
65
  link: (text: string) => string;
64
66
  linkUrl: (text: string) => string;
67
+ /** Resolve the OSC 8 destination without changing visible text; undefined preserves the authored URL. */
68
+ resolveLink?: (href: string) => string | undefined;
65
69
  code: (text: string) => string;
66
70
  codeBlock: (text: string) => string;
67
71
  codeBlockBorder: (text: string) => string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@oh-my-pi/pi-tui",
4
- "version": "18.1.8",
4
+ "version": "18.1.9",
5
5
  "description": "Terminal User Interface library with differential rendering for efficient text-based applications",
6
6
  "homepage": "https://omp.sh",
7
7
  "author": "Stencil Labs, Inc.",
@@ -37,8 +37,8 @@
37
37
  "fmt": "oxfmt --no-error-on-unmatched-pattern 'src/**/*.{ts,tsx}' '{test,bench,examples,scripts}/**/*.ts' '*.ts'"
38
38
  },
39
39
  "dependencies": {
40
- "@oh-my-pi/pi-natives": "18.1.8",
41
- "@oh-my-pi/pi-utils": "18.1.8"
40
+ "@oh-my-pi/pi-natives": "18.1.9",
41
+ "@oh-my-pi/pi-utils": "18.1.9"
42
42
  },
43
43
  "devDependencies": {
44
44
  "kitty-vt-wasm": "^0.2.0"
@@ -1346,6 +1346,15 @@ export interface HighlightStreamSession {
1346
1346
  push(chunk: string): string;
1347
1347
  }
1348
1348
 
1349
+ /** Collect distinct hyperlink destinations using the renderer's Markdown grammar, excluding images and code. */
1350
+ export function getMarkdownLinkUrls(text: string): string[] {
1351
+ const urls = new Set<string>();
1352
+ markdownParser.walkTokens(markdownParser.lexer(text), token => {
1353
+ if (token.type === "link" && typeof token.href === "string") urls.add(token.href);
1354
+ });
1355
+ return [...urls];
1356
+ }
1357
+
1349
1358
  /**
1350
1359
  * Theme functions for markdown elements.
1351
1360
  * Each function takes text and returns styled text with ANSI codes.
@@ -1354,6 +1363,8 @@ export interface MarkdownTheme {
1354
1363
  heading: (text: string) => string;
1355
1364
  link: (text: string) => string;
1356
1365
  linkUrl: (text: string) => string;
1366
+ /** Resolve the OSC 8 destination without changing visible text; undefined preserves the authored URL. */
1367
+ resolveLink?: (href: string) => string | undefined;
1357
1368
  code: (text: string) => string;
1358
1369
  codeBlock: (text: string) => string;
1359
1370
  codeBlockBorder: (text: string) => string;
@@ -3208,7 +3219,8 @@ export class Markdown implements Component {
3208
3219
  const linkText = this.#renderInlineTokens(token.tokens || [], resolvedStyleContext);
3209
3220
  const styledLinkText = this.#theme.link(this.#theme.underline(linkText));
3210
3221
  const href = typeof token.href === "string" ? token.href : "";
3211
- const clickableLinkText = formatHyperlink(styledLinkText, href);
3222
+ const target = (href && this.#theme.resolveLink?.(href)) || href;
3223
+ const clickableLinkText = formatHyperlink(styledLinkText, target);
3212
3224
  // If link text matches href, only show the link once. A missing
3213
3225
  // href (malformed/partial link token) renders as plain link text
3214
3226
  // instead of crashing the renderer or emitting an empty "()"
@@ -3221,7 +3233,7 @@ export class Markdown implements Component {
3221
3233
  result += clickableLinkText + stylePrefix;
3222
3234
  else {
3223
3235
  const styledLinkUrl = this.#theme.linkUrl(`(${href})`);
3224
- result += `${clickableLinkText} ${formatHyperlink(styledLinkUrl, href)}${stylePrefix}`;
3236
+ result += `${clickableLinkText} ${formatHyperlink(styledLinkUrl, target)}${stylePrefix}`;
3225
3237
  }
3226
3238
  break;
3227
3239
  }