spectreconsole / errata

A library that makes it easy to create and display diagnostics of different kinds.
MIT License
342 stars 13 forks source link

Rendering to a string? #12

Open andrzejolszak opened 2 years ago

andrzejolszak commented 2 years ago

I was looking for a way to render Reports to a string (accepting drawbacks like losing the colors, monospace font requirement for display, etc.), and it seems that this would require implementing a special IAnsiConsole.

Do this sound viable, or would expect problems? Or maybe there is already a way to do this that I just haven't found?

Thanks!

patriksvensson commented 2 years ago

@andrzejolszak Should be possible to do. You have two options here, either implement a custom IAnsiConsole, or implement a IAnsiConsoleRecorder and use the record functionality of IAnsiConsole. There should already be a text recorder in Spectre.Console that should do what you need.

Will add an example once I'm at a computer.