mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-03 21:36:36 +00:00
Best way to unescape HTML code in code blocks #240
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 @pacman21 on GitHub (Oct 29, 2018).
I have a need to unescape HTML code that we inject into our markdown, more or less, as a hack to get features that markdown generally doesn't support. What is the best way to go about this? I'm trying to create a custom extension, however I haven't been able to figure out how to modify the contents of the code block. I looked through the code and some of the documentation to try to find this, but haven't really ran into anything.
Can you point in the right direction to find some documentation related to this?
@Kryptos-FR commented on GitHub (Oct 29, 2018):
Shouldn't that HTML directly be in the markdown document as-is, instead of inside a code-block? I thought that was the default behavior for markdown document: if it is HTML render it as-is if not parse markdown syntax.
@xoofx commented on GitHub (Oct 29, 2018):
@pacman21 could you provide a more concrete example of what you are trying to achieve? markdig does support HTML tags (block and inlines) as per the CommonMark specs, so wondering exactly what is missing on your side?
@pacman21 commented on GitHub (Oct 29, 2018):
My apologies for the lack of examples provided and thank you for your swift assistance.
The markdown (value) I am passing in is:
After I run the following command
The HTML output I receive is:
How do I get the span tags to render as spans instead of being encoded?
@Kryptos-FR commented on GitHub (Oct 30, 2018):
Don't put them inside a code block but directly as-is.
See the result on https://babelmark.github.io
@xoofx commented on GitHub (Oct 30, 2018):
The text inside a code block is rendered as literal text and escaped as required by the CommonMark specs.
You will have to hack something on your side if you want a different behavior.