@@ -36,6 +36,7 @@ pub struct GraphicalReportHandler {
36
36
pub ( crate ) word_separator : Option < textwrap:: WordSeparator > ,
37
37
pub ( crate ) word_splitter : Option < textwrap:: WordSplitter > ,
38
38
pub ( crate ) highlighter : MietteHighlighter ,
39
+ pub ( crate ) link_display_text : Option < String > ,
39
40
}
40
41
41
42
#[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
@@ -62,6 +63,7 @@ impl GraphicalReportHandler {
62
63
word_separator : None ,
63
64
word_splitter : None ,
64
65
highlighter : MietteHighlighter :: default ( ) ,
66
+ link_display_text : None ,
65
67
}
66
68
}
67
69
@@ -80,6 +82,7 @@ impl GraphicalReportHandler {
80
82
word_separator : None ,
81
83
word_splitter : None ,
82
84
highlighter : MietteHighlighter :: default ( ) ,
85
+ link_display_text : None ,
83
86
}
84
87
}
85
88
@@ -190,6 +193,13 @@ impl GraphicalReportHandler {
190
193
self . highlighter = MietteHighlighter :: nocolor ( ) ;
191
194
self
192
195
}
196
+
197
+ /// Sets the display text for links.
198
+ /// Miette displays `(link)` if this option is not set.
199
+ pub fn with_link_display_text ( mut self , text : impl Into < String > ) -> Self {
200
+ self . link_display_text = Some ( text. into ( ) ) ;
201
+ self
202
+ }
193
203
}
194
204
195
205
impl Default for GraphicalReportHandler {
@@ -246,11 +256,12 @@ impl GraphicalReportHandler {
246
256
} else {
247
257
"" . to_string ( )
248
258
} ;
259
+ let display_text = self . link_display_text . as_deref ( ) . unwrap_or ( "(link)" ) ;
249
260
let link = format ! (
250
261
"\u{1b} ]8;;{}\u{1b} \\ {}{}\u{1b} ]8;;\u{1b} \\ " ,
251
262
url,
252
263
code. style( severity_style) ,
253
- "(link)" . style( self . theme. styles. link)
264
+ display_text . style( self . theme. styles. link)
254
265
) ;
255
266
write ! ( header, "{}" , link) ?;
256
267
writeln ! ( f, "{}" , header) ?;
0 commit comments