MarkdownSharp / Markdown.NET: how to extract unformatted text from markdowns?

It is sometimes useful to convert markdowns into plain text (for example, for sending by email).

Does any of these libraries support this functionality? (I'm actually more interested in MarkdownSharp)

EDIT

Reply to Jorn's comment. I will clarify what I expect from such a conversion:
Markdown has special characters that, depending on the context, have only a formatting value. For example, the characters **, =, -. It would be nice if I could clear the text of the formatting characters.

I’m not sure what the best approach would be and what characters should be removed, and I don’t know what to do with links, for example, but I think that someone could have done something in this sense earlier.

EDIT 2

Found a good example: Stackoverflow uses this type of markdown removal in the "Questions" list. I am sure that it clears the formatting of the mark before passing the summary of the question, otherwise it will contain line breaks, strengths, H1, etc.

EDIT 3

I agree with John. The best solution seems to be to convert from markdowns to HTML and then remove the resulting HTML code.

And this task seems to have already been solved: How can I remove HTML from text in .NET?

+4
source share
1 answer

If you just want to keep the source, just don't pass it to Markdown.

Markdown is just one thing: turning Markdown text into HTML. If you want Markdown to format it in something different from HTML with a different set of conversion rules, then, alas, you will have to write your own transformer.

If you want to get a text version of an already formatted HTML Markdown format, you can simply remove the HTML tags. This is what StackOverflow does.

+2
source

All Articles