mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-03 21:36:36 +00:00
Setting ImplicitParagraph has no effect #339
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @sklivvz on GitHub (Jan 5, 2020).
As far as I understand, setting
ImplicitParagraphtofalseshould prevent markdig from wrapping rendered HTML in a<p>.However, the following test does not behave as expected
Furthermore, this parameter (and the couple more similar) are only interesting at render time and as such, they should be directly settable -- the user should not be forced to go through 5 lines of setup to set a basic option, such as when rendering a snippet. This also makes them basically undiscoverable.
@xoofx commented on GitHub (Jan 5, 2020):
I don't remember the details of this particular parameter, but these parameters on the Renderer class are often render states used by the renderers and not always settable by end-user. So their discover-ability was absolutely not a concern, unless you want to develop a new custom renderer.
Well, the situation could have been worse, I could have decided back in the days to make them completely internal. But at least, the API is giving you a chance to have an access for it, so that's not that bad right?
I'm no longer in the details of the API to propose anything right now, nor I have dedicated personal time to track this, so if you could take the time to make a proposal, and a PR, that would be helpful.
@MihaZupan commented on GitHub (Jan 5, 2020):
ImplicitParagraphis false by default, if you don't want paragraph tags, set it to true.Also
Markdown.ToHtmlcreates its own renderer. If you create your ownHtmlRendereryou have to render on it explicitly like so:I agree it's not user-friendly rn, you are pretty much copying the implementation of
ToHtml. I was thinking of adding another helper method, something like:So this example would become
@sklivvz commented on GitHub (Jan 5, 2020):
OK, so first of all thanks for clarifying the problem and its solution. I agree that a helper method would improve the situation, perhaps with some extra docs.
This worked for me, although it needs to be moved to the right class, tested etc.
If you like the approach I'll push a PR tomorrow
Thanks,
@MihaZupan commented on GitHub (Jan 5, 2020):
If @xoofx agrees with the API shape, the implementation would probably be like so:
(note that I changed the parameters)
Might be cleaner to reverse
configureRendererandpipelineand make pipeline non-default as I would imagine most callers will specify it and having anActionas a last parameter is usually more readable.@audigex commented on GitHub (Oct 14, 2020):
I feel like this is all massively overcomplicated for the end user, for something that seems so basic and fundamental. Clearly there are a lot of situations where the user is going to want to render markdown inline.
It seems like this is all just a very roundabout way of handling something that should be done with the existence of
ToInlineHtml()orToHtml(bool inline = false)@MihaZupan commented on GitHub (Oct 14, 2020):
I don't know if this specific case is so common that a dedicated overload would be necessary.
Most users requiring fine-grained control will likely want to adjust more than one thing and will already be doing the pipeline setup and rendering steps manually.
@kinetiq commented on GitHub (Sep 19, 2023):
@MihaZupan For what it's worth, I need it and I'm frustrated. I imagine this must be very common (especially considering the upvotes on the comment asking for an overload).
I've been poking around trying to find a solution that isn't an overblown hack but I'm giving up - I'm going to go do it the ugly way. :)
@xoofx commented on GitHub (Sep 19, 2023):
Let me reiterate from my original response, that if someone wants such a feature, this person will have to make a PR for it with tests. 🙂
@vsvsav commented on GitHub (Oct 7, 2024):
Nope. I need it too. Additional wrapping the final text is not always a good idea, because if it is text inside a label+checkbox, the text will start on a new line.
@IIARROWS commented on GitHub (Mar 2, 2025):
Same here... I have an already existing structure, I have to put markdown text inside a span (just for emphasis like bold and italics), which of course cannot contain a paragraph.
Right now I'm calling
Markdig.Markdown.ToHtmlpassing a string and a custom pipeline.I think the proposal from sklivvz works nice. Hiding boilerplate from the caller is really helpful.
As far as I care, it should just be part of the pipeline. Add something like "UseNoWrapper" or whatever, seems really logical to me, it just have to prevent placing the paragraph tags at the beginning and end segment.
If the string then has other tags like titles, it's a user problem.