showdownjs / showdown

A bidirectional Markdown to HTML to Markdown converter written in Javascript
http://www.showdownjs.com/
MIT License
14.26k stars 1.56k forks source link

Clean markdown characters, leave only clean text. #829

Open smoleniuch opened 4 years ago

smoleniuch commented 4 years ago

I want to make an html element on my website that is responsible for displaying news articles. I am only displaying title and sample of the article content as preview.If user wants to read full article he can switch mode to see all the content with markdown parsed as html.

Value of the article content is stored as markdown and is converted to HTML on the client side.

I would like to make sample of article content as simple as it can be, stripped of any special markdown characters. Is there any simple solution to strip these characters and leave only simple text?

Isomorphic-Router-Demo-news-preview

Isomorphic-Router-Demo-news-fullview

Is it worth to make an extension for such usecase?

tivie commented 2 years ago

it's indeed possible to make an extension to strip all markdown special characters. however, it might be hard to account for everything since stuff such as newlines count as markdown too. Maybe it's easier to let showdown parse the text as HTML ad then strip the HTML tags