A
A
Alex Ant2016-11-12 20:54:39
Yii
Alex Ant, 2016-11-12 20:54:39

How to convert string variable with html tags to html document?

Hello fellow programmers!
The essence of the question is as follows:
There is a $content variable of the form:

# This is a string \n\n https://s10.postimg.org/nqmx035d5/image.jpg\n\nPresent to you is the first

:
As you can see, markdown is used here for formatting, at the output I want to get correctly processed text, but I get the text completely taken into the h1 tag, i.e. does not treat \n as a line ending when processing markdown.
I tried to replace br with \n, it does not help.
I handle markdown like this:
$show = Markdown::convert($show);
At the same time, if I put enter in the database to transfer to a new line, the processing is correct.
What do I need to replace \n with so that the text is processed correctly?
Maybe first somehow send html to the output, pick it up, and then finish it with a markdown? But it looks somehow .. Wrong.) Tell me?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Timofeev, 2016-11-12
@webinar

demos.krajee.com/markdown-details/markdown-converter

A
Alex Ant, 2016-11-12
@AN_ANT

Yes, I am using this module. The trick is that I don't have end tags
$content = '### Heading 3 ###'
And markdown doesn't recognize line break tags by itself. At the same time, if you put enter in the text of the variable (text in the database), then the markdown works fine.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question