mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-13 05:45:31 +00:00
Strikethrough (~~) renders as empty angle brackets #599
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 @daughtkom on GitHub (Apr 14, 2023).
I have a situation that I have worked around that seems like it might be a bug, but I acknowledge that this might be by design and that I have just misunderstood something.
I have this markdown in a variable named
markdown:I have added the emphasis extras and was having an issue. (I have tried both with and without
EmphasisExtraOptions.Strikethrough.)The following is the generated HTML:
I have also tested with
~,+,^, and all give the same result with empty tags.I am using:
All that said, if I pass the
pipelineagain to theToHtmlcall, it does render the tags correctly. I would have thought that since I createddocwith the pipeline that I wouldn't need to use it again when callingToHtml.Is this a bug, or by design? Any suggestions what I am missing?
@MihaZupan commented on GitHub (Apr 14, 2023):
Did you pass the pipeline to
ToHtml/your renderer instance?@daughtkom commented on GitHub (Apr 14, 2023):
That was the workaround that I mentioned at the bottom of my description, and that does work. I updated my description to include this.
This wasn't obvious since I had used pipeline with
Parseto create the document. I haven't found much documentation so my usage was self-taught. I guess I thought that since the pipeline was used to create the document, that callingdoc.ToHtml()would use the same pipeline.Maybe not? If not, then does passing it in
Markdown.Parse(markdown, pipeline)do anything?@MihaZupan commented on GitHub (Apr 14, 2023):
Markdig processes input in two stages:
MarkdownDocument)Both of these are highly extensible. You can add parsers that change the shape of the syntax tree or add their own custom nodes. You can inspect/modify the syntax tree before rendering. You can then add renderers that understand those custom nodes and know what to do with them.
The pipeline represents the set of parsers and renderers to use. When using extensions (e.g.
UseEmphasisExtras), you need the renderer to be aware of what sort of elements it can expect parsers to emit.For your example input, the document represents the following:
if you don't pass the pipeline to the renderer, the renderer doesn't know what to do with an
EmphasisInlinethat hasDelimiterChar='~'.If you don't care about looking at the AST, you can also use the
helper.
Docs could certainly be improved 😄
@daughtkom commented on GitHub (Apr 14, 2023):
Thanks. That does help explain.