0

我在 Laravel 应用程序中使用 PHP League Commonmark 包。Commonmark 的 convertToHtml() 返回用双引号括起来的 html。当然,此内容是在显示 html 标记的页面上呈现的。我正在使用演示者来转换从我的数据库返回的 md。我已经确认数据库中的内容中没有引号。

我以前用过这个包,找不到我做错了什么。谁能指出我正确的方向?

这是我的演示者(扩展类是 Laracasts 演示者):

class ContentPresenter extends Presenter
{
private $markdown;

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

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

}
4

1 回答 1

1

我在 Blade 模板中使用了不正确的括号格式。我使用的是 {{ }},它转义了内容。我切换到{!!!},它不会转义内容。

有关更多信息,请参阅此 SO 答案:https ://stackoverflow.com/a/35031303/4374801

感谢以上所有在评论中提供了巨大帮助的人。

于 2017-02-05T21:45:12.413 回答