我在Laravel应用程序中使用PHP League Commonmark包。 Commonmark的convertToHtml()返回用双引号括起来的html。当然,此内容在显示html标签的页面上呈现。我正在使用演示者转换从我的数据库返回的md。我已确认db中的内容中没有引号。
我以前用过这个包,找不到我做错了什么。 有人能指出我正确的方向吗?
这是我的演示者(扩展类是Laracasts演示者):
class ContentPresenter extends Presenter
{
private $markdown;
public function bodyHtml()
{
$this->markdown = new CommonMarkConverter();
return $this->body ? $this->markdown->convertToHtml($this->body) : null;
}
}
答案 0 :(得分:1)
我在Blade模板中使用了错误的括号格式。我使用{{}},它逃脱了内容。我切换到{!! !!},它不会逃避内容。
请参阅此SO答案了解更多信息:https://stackoverflow.com/a/35031303/4374801
感谢上述所有人在评论中给予了极大的帮助。