miette icon indicating copy to clipboard operation
miette copied to clipboard

Bug: Link field with ANSI characters inside `GraphicalTheme::none/unicode_nocolor` using the `GraphicalReportHandler`

Open Boshen opened this issue 3 years ago • 3 comments

I'm currently making snapshot tests with non-ansi theme:

miette::GraphicalReportHandler::new_themed(miette::GraphicalTheme::unicode_nocolor())

but it produces ansi characters for the links:

]8;;https://eslint.org/docs/rules/no-cond-assign\(link)]8;;\

It seems like the characters are hard code here: https://github.com/zkat/miette/blob/714334098a92c77fb6b962e627defab7e16b540d/src/handlers/graphical.rs#L167-L172

Expected Outcome

I'm expecting GraphicalTheme::unicode_nocolor() and GraphicalTheme::none() to produce no ansi characters for the link field inside the GraphicalReportHandler

Boshen avatar May 17 '22 16:05 Boshen

These aren't part of the theme because they're actually determined by the link style. You can disable them by setting .with_links(false) in your GraphicalReportHandler.

zkat avatar May 17 '22 16:05 zkat

It seems .with_links(false) sets LinkStyle::Text, then it got omitted here and the link stopped showing up 😂 :

https://github.com/zkat/miette/blob/714334098a92c77fb6b962e627defab7e16b540d/src/handlers/graphical.rs#L160

should this be self.links != LinkStyle::None?

Boshen avatar May 18 '22 07:05 Boshen

Why self.links != LinkStyle::None? That would make the link spit out the ANSI characters even when the user requests that the link only be rendered as plain text.

zkat avatar Jul 24 '22 17:07 zkat