I have a lot of different blog posts in a database. They are in markdown. I want to convert them to html. I have problems with the ul tag.
For instance in a simplified way I have that:
Something
- First
- Second
Something else
Second ul
- First
- Second
Some final text
I could put the li tags:
$text = preg_replace("/^- (.*)/m", "<li>$1</li>", $text);
But how can I identify the beginning or end of the list to put the ul tag?
I want this result:
Something
<ul>
<li>- First</li>
<li>- Second</li>
</ul>
Something else
Second ul
<ul>
<li>- First</li>
<li>- Second</li>
</ul>
Some final text