naba0123 / commonmark-ext-img-url-prefix
Extension for league/commonmark to add prefix to src url of Img tag with specitific distinction
Installs: 55
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/naba0123/commonmark-ext-img-url-prefix
Requires
- php: ^7.4
- league/commonmark: ^1.3
Requires (Dev)
- phpunit/phpunit: ^9.5
README
Extension for league/commonmark to add prefix url to img with specitific distinction.
https://packagist.org/packages/naba0123/commonmark-ext-img-url-prefix
Install
composer require naba0123/commonmark-ext-img-url-prefix
Example
$environment = \League\CommonMark\Environment::createCommonMarkEnvironment();
$environment->addExtension(new \Naba0123\CommonMark\Ext\ImgPreUrl\ImgPreUrlExtension());
$converter = new \League\CommonMark\CommonMarkConverter([
'img_pre_url-pre_url' => '/example/dir/',
'img_pre_url-distinction_char' => '@',
], $environment);
echo $converter->convertToHtml('');
The above is converted to Img tag as the following
<img src="/example/dir/path.jpg" alt="Alt Text">