eberdna/commonmark-ext-prepend-image

添加了预置图片路径/路由的可能性

安装: 54

依赖项: 0

建议者: 0

安全: 0

星标: 0

关注者: 1

分支: 0

开放问题: 0

类型:commononmark-extension

1.0.0 2020-09-23 12:15 UTC

This package is auto-updated.

Last update: 2024-09-23 21:35:29 UTC


README

Tests

此功能为 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('![alt text](image.jpg)');

这会创建以下HTML

<p><img src="/path/to/files/image.jpg" alt="alt text" /></p>

请注意,只有当Markdown图片路径不以 '/''//''http' 开头时,才会预置路径。

选项

此扩展没有选项。在创建 PrependImageExtension 实例时,只能设置基本路径。