您不能使用 "markdown_to_html" 过滤器,因为没有可用的 Markdown 库
You cannot use the "markdown_to_html" filter as no Markdown library is available
我正在使用带有 PHP 7.4.24 和 Composer 2.1.8 的 Symfony 5.3.9。我想使用 markdown_to_html 呈现以下模板,但出现错误。
这是blog.html.twig
...
<article class="text-center">
{{ content | markdown_to_html }}
</article>
...
这是我得到的错误:
An exception has been thrown during the rendering of a template ("You cannot use the "markdown_to_html" filter as no Markdown library is available; try running "composer require league/html-to-markdown".").
我 运行 composer require league/html-to-markdown
但它显示“没有要安装、更新或删除的内容”。
我的composer.json:
{
"type": "project",
"license": "proprietary",
"require": {
"php": "^7.4.24",
"ext-ctype": "*",
"ext-iconv": "*",
"composer/package-versions-deprecated": "^1.10",
"doctrine/annotations": "^1.0",
"doctrine/doctrine-bundle": "^2.1",
"doctrine/doctrine-migrations-bundle": "^3.0",
"doctrine/orm": "^2.7",
"league/html-to-markdown": "^5.0",
"phpdocumentor/reflection-docblock": "^5.2",
"sensio/framework-extra-bundle": "^5.5",
"symfony/apache-pack": "^1.0",
"symfony/asset": "5.3.*",
"symfony/console": "5.3.*",
"symfony/dotenv": "5.3.*",
"symfony/expression-language": "5.3.*",
"symfony/flex": "^1.3.1",
"symfony/form": "5.3.*",
"symfony/framework-bundle": "5.3.*",
"symfony/http-client": "5.3.*",
"symfony/intl": "5.3.*",
"symfony/mailer": "5.3.*",
"symfony/mime": "5.3.*",
"symfony/monolog-bundle": "^3.1",
"symfony/notifier": "5.3.*",
"symfony/process": "5.3.*",
"symfony/property-access": "5.3.*",
"symfony/property-info": "5.3.*",
"symfony/runtime": "5.3.*",
"symfony/security-bundle": "5.3.*",
"symfony/serializer": "5.3.*",
"symfony/string": "5.3.*",
"symfony/translation": "5.3.*",
"symfony/twig-bundle": "5.3.*",
"symfony/validator": "5.3.*",
"symfony/web-link": "5.3.*",
"symfony/yaml": "5.3.*",
"twig/cssinliner-extra": "^3.3",
"twig/extra-bundle": "^3.3",
"twig/inky-extra": "^3.3",
"twig/markdown-extra": "^3.3",
"twig/twig": "^2.12|^3.0"
},
"require-dev": {
"symfony/browser-kit": "^5.3",
"symfony/css-selector": "^5.3",
"symfony/debug-bundle": "^5.3",
"symfony/maker-bundle": "^1.20",
"symfony/phpunit-bridge": "^5.3",
"symfony/stopwatch": "^5.3",
"symfony/var-dumper": "^5.3",
"symfony/web-profiler-bundle": "^5.3"
},
"config": {
"optimize-autoloader": true,
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"App\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\Tests\": "tests/"
}
},
"replace": {
"paragonie/random_compat": "2.*",
"symfony/polyfill-ctype": "*",
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php72": "*",
"symfony/polyfill-php71": "*",
"symfony/polyfill-php70": "*",
"symfony/polyfill-php56": "*"
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
"@auto-scripts"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"allow-contrib": false,
"require": "5.3.*"
}
}
}
我已遵循此文档 https://twig.symfony.com/doc/3.x/filters/markdown_to_html.html。我做错了什么?
解决办法是执行:
composer require league/commonmark
twig/markdown-extra 包只是提供了一个用于调用 markdown 处理器的 twig 扩展。您仍然需要安装一个实际的降价包。这在 markdown_to_html 页面的最后有记录,但不是很清楚。
如果未找到降价包,则发出 html_to_markdown 建议。如果这是需要的,那会很好,但 markdown_to_html 是一个更常见的要求。因此所有的评论。该建议将在下一个版本中修复。
仅供参考,联盟包并不是唯一受支持的包。您还可以使用:
"require-dev": {
"erusev/parsedown": "^1.7",
"league/commonmark": "^1.0",
"league/html-to-markdown": "^4.8|^5.0",
"michelf/php-markdown": "^1.8"
如markdown-extra/composer中所列。json
我正在使用带有 PHP 7.4.24 和 Composer 2.1.8 的 Symfony 5.3.9。我想使用 markdown_to_html 呈现以下模板,但出现错误。
这是blog.html.twig
...
<article class="text-center">
{{ content | markdown_to_html }}
</article>
...
这是我得到的错误:
An exception has been thrown during the rendering of a template ("You cannot use the "markdown_to_html" filter as no Markdown library is available; try running "composer require league/html-to-markdown".").
我 运行 composer require league/html-to-markdown
但它显示“没有要安装、更新或删除的内容”。
我的composer.json:
{
"type": "project",
"license": "proprietary",
"require": {
"php": "^7.4.24",
"ext-ctype": "*",
"ext-iconv": "*",
"composer/package-versions-deprecated": "^1.10",
"doctrine/annotations": "^1.0",
"doctrine/doctrine-bundle": "^2.1",
"doctrine/doctrine-migrations-bundle": "^3.0",
"doctrine/orm": "^2.7",
"league/html-to-markdown": "^5.0",
"phpdocumentor/reflection-docblock": "^5.2",
"sensio/framework-extra-bundle": "^5.5",
"symfony/apache-pack": "^1.0",
"symfony/asset": "5.3.*",
"symfony/console": "5.3.*",
"symfony/dotenv": "5.3.*",
"symfony/expression-language": "5.3.*",
"symfony/flex": "^1.3.1",
"symfony/form": "5.3.*",
"symfony/framework-bundle": "5.3.*",
"symfony/http-client": "5.3.*",
"symfony/intl": "5.3.*",
"symfony/mailer": "5.3.*",
"symfony/mime": "5.3.*",
"symfony/monolog-bundle": "^3.1",
"symfony/notifier": "5.3.*",
"symfony/process": "5.3.*",
"symfony/property-access": "5.3.*",
"symfony/property-info": "5.3.*",
"symfony/runtime": "5.3.*",
"symfony/security-bundle": "5.3.*",
"symfony/serializer": "5.3.*",
"symfony/string": "5.3.*",
"symfony/translation": "5.3.*",
"symfony/twig-bundle": "5.3.*",
"symfony/validator": "5.3.*",
"symfony/web-link": "5.3.*",
"symfony/yaml": "5.3.*",
"twig/cssinliner-extra": "^3.3",
"twig/extra-bundle": "^3.3",
"twig/inky-extra": "^3.3",
"twig/markdown-extra": "^3.3",
"twig/twig": "^2.12|^3.0"
},
"require-dev": {
"symfony/browser-kit": "^5.3",
"symfony/css-selector": "^5.3",
"symfony/debug-bundle": "^5.3",
"symfony/maker-bundle": "^1.20",
"symfony/phpunit-bridge": "^5.3",
"symfony/stopwatch": "^5.3",
"symfony/var-dumper": "^5.3",
"symfony/web-profiler-bundle": "^5.3"
},
"config": {
"optimize-autoloader": true,
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"App\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\Tests\": "tests/"
}
},
"replace": {
"paragonie/random_compat": "2.*",
"symfony/polyfill-ctype": "*",
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php72": "*",
"symfony/polyfill-php71": "*",
"symfony/polyfill-php70": "*",
"symfony/polyfill-php56": "*"
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
"@auto-scripts"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"allow-contrib": false,
"require": "5.3.*"
}
}
}
我已遵循此文档 https://twig.symfony.com/doc/3.x/filters/markdown_to_html.html。我做错了什么?
解决办法是执行:
composer require league/commonmark
twig/markdown-extra 包只是提供了一个用于调用 markdown 处理器的 twig 扩展。您仍然需要安装一个实际的降价包。这在 markdown_to_html 页面的最后有记录,但不是很清楚。
如果未找到降价包,则发出 html_to_markdown 建议。如果这是需要的,那会很好,但 markdown_to_html 是一个更常见的要求。因此所有的评论。该建议将在下一个版本中修复。
仅供参考,联盟包并不是唯一受支持的包。您还可以使用:
"require-dev": {
"erusev/parsedown": "^1.7",
"league/commonmark": "^1.0",
"league/html-to-markdown": "^4.8|^5.0",
"michelf/php-markdown": "^1.8"
如markdown-extra/composer中所列。json