boxofyellow / ConsoleMarkdownRenderer

Library for rendering markdown within the console
https://www.nuget.org/packages/BoxOfYellow.ConsoleMarkdownRenderer
MIT License
2 stars 0 forks source link

Get rid of the Uri in DisplayRenderer #2

Open raffaeler opened 2 weeks ago

raffaeler commented 2 weeks ago

Is your feature request related to a problem? Please describe. It looks like this library is meant to only render complete markdown contents read by files or network. Instead, I want to print formatted content on the console "on the fly" as a rich logger. I would also love to map the markdown formatting to ConsoleColor so that I can format a title in Red instead of ## Title ## and get rid of the # entirely.

Describe the solution you'd like I am trying to use the Displayer like this: Displayer.DisplayMarkdown(content, new Uri("about:blank")); but I am not sure why I should specify the Uri at all.

Describe alternatives you've considered I don't see any alternatives

boxofyellow commented 2 weeks ago

The uri in the versions that you referenced is to denote the base address that should be use for resolving relative links within the document. So removing it would relative links could no longer be resolved.

That being said a Uri to a local file would likely get the job done, but again that would only work if you ensure relieve links are not in the content you provide.

Providing options to allow mapping the mark down to ConsoleColors would be interesting enhancement. I'm not sure when I will have time to invest in something like that, but I would be open accepting PRs.

boxofyellow commented 1 week ago

@raffaeler so I did have some time, so I created this

I'll likely merge it soon, but let me know if you had different thoughts.

raffaeler commented 1 week ago

Sorry for the delay but I was traveling.

That being said a Uri to a local file would likely get the job done, but again that would only work if you ensure relieve links are not in the content you provide.

I am aware of this, I think that we have two different use-cases in mind. In a classic Console, here you just print messages, the Uri parameter could be at least "about:blank" by default otherwise you have the impression that it won't work unless there is an Uri specified. In other scenarios, where you want to render a content took by the internet, the Uri must be specified, we all agree on this.

Said that, I would opt for the optional parameters with a default "fake" Uri.

Also, if you can spend time in adding comments, that would help a lot as well.

Thanks

raffaeler commented 1 week ago

@raffaeler so I did have some time, so I created this

I'll likely merge it soon, but let me know if you had different thoughts.

Thank you, I commented on the PR directly, well done :)

boxofyellow commented 1 week ago

I merged that PR and trigger publishing a new version of the nuget package https://www.nuget.org/packages/BoxOfYellow.ConsoleMarkdownRenderer/0.6.0 So I think we should be ready to close this one out.

@raffaeler Thanks for the suggestion and a reason to revisit an old project

boxofyellow commented 1 week ago

I'll think on this one some more

Said that, I would opt for the optional parameters with a default "fake" Uri.

So lets leave this one open for now.

raffaeler commented 1 week ago

Thank you for the prompt change. I commented on the PR with a couple of questions on coloring titles