mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-03 21:36:36 +00:00
Strip markdown #104
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 @ProsperoTheBun on GitHub (Mar 24, 2017).
Feature Request:
It would be useful to be able to remove all markdown without converting to HTML. E.g, for a preview of a blog's body text.
So an input like ...
Would produce
@ProsperoTheBun commented on GitHub (Mar 24, 2017):
FYI, I workaround this on webpages by using jQuery to read the "text" of the element then write it back in.
But for my app feed API, I'd rather do this server-side.
@leotsarev commented on GitHub (May 14, 2017):
Note that's a good practice to sanitize HTML anyway (as markdown parsers do not sanitize). Most of HTML sanitizers could remove all html anyway
@xoofx commented on GitHub (May 18, 2017):
Markdown at its first origin is text oriented, so that even a simple bullet point list would be readable in plain text. So in your examples above, removing the
-for the list even for displaying as text is quite an opinionated "preview"... For other markdown elements, I can also see quite different ways to output a text preview (emphasis could remove, but links? still displaying the link or not?...etc.)Personally don't have time nor special interest in this feature, but a PR is welcome.
Note that
HtmlRendererhas already a propertyEnableHtmlForInline, that is currently working only for inlines. If someone wants to work on this PR, you can still use the HtmlRenderer, but add aEnableHtmlForBlock, and revisit all html block renderers (like theHeadingRenderer) and enclose with if/else the portions that are outputing HTML (but keep at least theWriteLineto keep a reasonable structure of the text)@xoofx commented on GitHub (Sep 12, 2017):
Errata about my previous comment: If someone wants to provide such feature, I would much prefer that we do this work as part of #32, as it covers broader use cases.
@xoofx commented on GitHub (Sep 12, 2017):
Actually, scratch that... #32 is probably not ideal either if we want to keep only text... Let me think about this...
@xoofx commented on GitHub (Oct 24, 2017):
So this should be fixed by PR #140 that was just merged to master
@xoofx commented on GitHub (Oct 24, 2017):
So the workaround for this issue is to use a
HtmlRendererand setting bothEnableHtmlForInlineandEnableHtmlForBlocktofalse@leotsarev commented on GitHub (Oct 27, 2017):
I submitted public API facade for this. I wonder if you are open to change like that, I'm happy to expand if required.