phplaravel-5commonmark

PHP League Commonmark returns HTML wrapped in quotes


I am using the PHP League Commonmark package in a Laravel application. Commonmark's convertToHtml() is returning html wrapped in double quotes. This content is, of course, rendered on the page with the html tags displayed. I am using a presenter to convert the md that is returned from my DB. I have confirmed that there are no quotes in the content in the db.

I have used the package before, and cannot find what I am doing wrong. Can anyone point me in the right direction?

Here is my presenter (the extended class is the Laracasts presenter):

class ContentPresenter extends Presenter
{
private $markdown;

public function bodyHtml()
{
    $this->markdown = new CommonMarkConverter();

    return $this->body ? $this->markdown->convertToHtml($this->body) : null;
}

}

Solution

  • I was using the incorrect bracket format in Blade templates. I was using {{ }}, which escapes content. I switched to {!! !!}, which does not escape the content.

    See this SO answer for more: https://stackoverflow.com/a/35031303/4374801

    Thanks to all above who helped tremendously in the comments.