Why isn't MarkdownSharp encoding my HTML?

后端 未结 3 1298
野趣味
野趣味 2021-02-20 14:48

In my mind, one of the bigger goals of Markdown is to prevent the user from typing potentially malformed HTML directly.

Well that isn\'t exactly working for me in Markdo

3条回答
  •  醉话见心
    2021-02-20 15:33

    For those not wanting to use Steve Wortham's customized solution, I have submitted an issue and a proposed fix to the MarkdownSharp guys: http://code.google.com/p/markdownsharp/issues/detail?id=43

    If you download my attached Markdown.cs file you will find a new option that you can set. It will stop MarkdownSharp from re-encoding text within the code blocks.

    Just don't forget to HTML encode your input BEFORE you pass it into markdown, NOT after.

    Another solution is to white-list HTML tags like Stack Overflow does. You would do this AFTER you pass your content to markdown.

    See this for more information: http://www.CodeTunnel.com/blog/post/24/mardownsharp-and-encoded-html

提交回复
热议问题