Open a tag using Markup() but close it later (question) #506
Replies: 3 comments
-
I'm not against adding support for non-terminated markup tags, but with great powers come great responsibility. There won't be any guarantees that a markup tag is closed and the output style being restored. I will need to think about this a bit and discuss it with @phil-scott-78. |
Beta Was this translation helpful? Give feedback.
-
Thank you kindly for the reply @patriksvensson - I've put |
Beta Was this translation helpful? Give feedback.
-
We've been thinking about this and concluded that this is not something that we would want to support until we've shipped version 1.0 of Spectre.Console. Thanks for opening the issue, though! |
Beta Was this translation helpful? Give feedback.
-
I'm writing a customizable MSFT Logger implementation for SpectreConsole. I need the ability to open a markup tag in order to apply styling to the event output, render the event, then close the tag after event rendering has been completed. My implementation has a whole pipeline around this. The styling per log level is customizable by the consumer, so these operations need to be isolated. I'd prefer not to have to build a string, my pipeline puts rendering fragments to the console bit by bit until the log event is rendered in full.
When I call the Markup() method it throws an exception because a styling tag isn't closed, even though I have the intention of closing it later. Is there any way to write incomplete markup to the call?
For now, I'll let the user customize just the foreground color, but it would be nice to be to define a complete markup (e.g. [blue on yellow]) in a string vs having to pick a color.
Beta Was this translation helpful? Give feedback.
All reactions