@@ -5,6 +5,10 @@ import { Table } from '@cliffy/table'
55import * as colors from '@std/fmt/colors'
66import { format as prettyBytes } from '@std/fmt/bytes'
77import { marked } from 'marked'
8+ // Imported libraries from import map (deno.json)
9+ import supportsHyperlinks from 'supports-hyperlinks'
10+ import ansiEscapes from 'ansi-escapes'
11+
812import type { SummaryOutput , ValidationResult } from '../types/validation-result.ts'
913import type { Issue , Severity } from '../types/issues.ts'
1014import type { DatasetIssues } from '../issues/datasetIssues.ts'
@@ -18,19 +22,6 @@ interface LoggingOptions {
1822 *
1923 * Returns the full output string with newlines
2024 */
21- function supportsHyperlinks ( ) : boolean {
22- // If NO_COLOR is set, usually we shouldn't render fancy links either
23- if ( Deno . env . get ( "NO_COLOR" ) ) {
24- return false ;
25- }
26- // Check specifically for terminals that support it (like iTerm, VSCode, etc.)
27- const termProgram = Deno . env . get ( "TERM_PROGRAM" ) ;
28- if ( [ "iTerm.app" , "vscode" , "Apple_Terminal" ] . includes ( termProgram || "" ) ) {
29- return true ;
30- }
31- return false ;
32- }
33-
3425export function consoleFormat (
3526 result : ValidationResult ,
3627 options ?: LoggingOptions ,
@@ -86,9 +77,10 @@ function renderTokens(tokenList: any[]): string {
8677 return colors . cyan ( token . text )
8778
8879 case 'link' :
89- if ( supportsHyperlinks ( ) ) {
90- // OSC-8 Hyperlink Sequence
91- return `\u001b]8;;${ token . href } \u001b\\${ token . text } \u001b]8;;\u001b\\`
80+ // Use the library to check for stdout support
81+ if ( supportsHyperlinks . stdout ) {
82+ // OSC-8 Hyperlink Sequence via ansi-escapes
83+ return ansiEscapes . link ( token . text , token . href )
9284 } else {
9385 // Fallback for terminals without support
9486 return `${ colors . blue ( token . text ) } (${ colors . gray ( token . href ) } )`
0 commit comments