I 'm using SmpleMDE as my WYSIWYG editor and the Parsedown library for parsing the markdown and converting it into HTML.
<?php echo $this->parsedown->text($post->content); ?>
Everything works fine, the only problem is that I want to show up
youtube videos within the content by adding the embeded <iframe>
.
According to this answer Youtube video and text side by side in Markdown I can simply add the youtube <iframe>
straight to my content, however the output shows the html code escaped
<p><iframe width="560" height="315" src="<a href="https://www.youtube.com/embed/7GqClqvlObY">https://www.youtube.com/embed/7GqClqvlObY</a>" frameborder="0" allowfullscreen></iframe></p>
The content in the database is stored like this
Lorem ipsum .....
<iframe width="560" height="315" src="https://www.youtube.com/embed/7GqClqvlObY" frameborder="0" allowfullscreen></iframe>
Lorem ipsum .....
How can I fix this so that the embeded code from youtube would show up properly?
Since the problem is that the strings are stored escaped in the database, try this:
<?php echo $this->parsedown->text(htmlspecialchars_decode($post->content); ?>
Also, take a look at the manual, you might have to add a flag depending on how your strings are encoded/escaped.