Deleting markdown formatting for quick subtraction

Does anyone know a script or an already created function that will help me create a fast shutter using existing formatted delimited content?

I look at formatting results such as StackOverflow, where I have a headline, and a short shutter speed, mainly for watching news. I want to completely remove markdowns and just keep a few words.

My concern is that I'm going to use the codeigniter word_limiter() helper to limit the output. What can create a damaged markdown:

 **This is a sentence which has some _markdown_ that is [cutoff.. 

So I'm not sure how to do this.

All my content is stored with markdowns (not HTML formatting), otherwise I would do "striptags", etc.

I found something similar for Ruby on SO here: Truncate Markdown? but I would like something for PHP.

I'm just not sure if I should just hide all the characters *_[]()> in principle? But if there is a URL (in half), I am worried that it will look nasty.

Thoughts? I looked around a little, but at first glance I did not find anything that cuts the stripes.

+6
source share
1 answer

Consider text markup, then do strip_tags.

- Update -

There are several other options, if you do not want text markup to separate tags, you can:

  • Enter a regular expression to highlight markdown items

  • Store content in a database without markup / markdown, just text

  • If you flag strip_tags, you can save the results in memcache to avoid unnecessary overhead

+11
source

Source: https://habr.com/ru/post/910759/


All Articles