html_to_markdown
的html_to_markdown
将一块HTML转换为减价过滤:
1 2 3 4 5
{%应用html_to_markdown %}<html><h1>你好!< /h1>< /html>{%endapply%}
您还可以使用过滤你整个模板包括
:
1
{{包括(“some_template.html.twig”)| html_to_markdown}}
请注意
的html_to_markdown
过滤器的一部分MarkdownExtension
这不是默认安装。安装:
1
美元需要树枝/ markdown-extra作曲家
在Sy欧宝娱乐app下载地址mfony项目,你可以通过安装自动启用它树枝/ extra-bundle
:
1
美元需要树枝/ extra-bundle作曲家
在树枝或添加扩展明确环境:
1 2 3 4
使用嫩枝\额外的\减价\MarkdownExtension;美元嫩枝=新\树枝\环境(…);美元嫩枝- >addExtension (新MarkdownExtension ());
如果你不使用Symfony,你还必须注册扩欧宝娱乐app下载地址展运行时:
1 2 3 4 5 6 7 8 9 10 11
使用嫩枝\额外的\减价\DefaultMarkdown;使用嫩枝\额外的\减价\MarkdownRuntime;使用嫩枝\RuntimeLoader\RuntimeLoaderInterface;美元嫩枝- >addRuntimeLoader (新类实现了RuntimeLoaderInterface{公共函数负载(美元类){如果(MarkdownRuntime::类= = =美元类){返回新MarkdownRuntime (新DefaultMarkdown ());}}});
html_to_markdown
只是一个前端;实际的转换是通过下列兼容库,您可以选择:
根据图书馆,还可以添加一些选项通过过滤器作为参数。的例子联盟/ html-to-markdown
:
1 2 3 4 5
{%应用html_to_markdown ({hard_break:假})%}<html><h1>你好!< /h1>< /html>{%endapply%}