eberdna / commonmark-ext-prepend-image
添加了预置图片路径/路由的可能性
1.0.0
2020-09-23 12:15 UTC
Requires
- league/commonmark: ^1.5
Requires (Dev)
- phpunit/phpunit: ^8.5
This package is auto-updated.
Last update: 2024-09-23 21:35:29 UTC
README
此功能为 league/commonmark 包添加了支持预置图片路径/路由的功能。
安装
composer require eberdna/commonmark-ext-prepend-image
示例
use League\CommonMark\Environment; use AndreBering\CommonMarkExtension\PrependImageExtension; $this->environment = Environment::createCommonMarkEnvironment(); $this->environment->addExtension(new PrependImageExtension('/path/to/files/')); $converter = new CommonMarkConverter([], $this->environment); $html = $converter->convertToHtml('');
这会创建以下HTML
<p><img src="/path/to/files/image.jpg" alt="alt text" /></p>
请注意,只有当Markdown图片路径不以 '/'
、'//'
或 'http'
开头时,才会预置路径。
选项
此扩展没有选项。在创建 PrependImageExtension
实例时,只能设置基本路径。