n0sz / commonmark-picture-extension
Adds support of picture tags to CommonMark PHP implementation
Installs: 9
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Type:commonmark-extension
Requires
- league/commonmark: ^2.3
Requires (Dev)
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-11-09 19:51:17 UTC
README
This library adds support of <picture>
tags to league/commonmark
Installation
This project can be install via composer:
composer require n0sz/commonmark-picture-extension
Usage
use League\CommonMark\Environment\Environment; use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension; use N0sz\CommonMark\Picture\PictureExtension; $environment = new Environment(); $environment->addExtension(new CommonMarkCoreExtension()); $environment->addExtension(new PictureExtension());
Syntax
Code:
[[[ + img_1 {media:"(min-width:650px)"} + img_2 {media:"(min-width:465px)"} - img_3 ]]]
Result:
<picture> <source media="(min-width:650px)" srcset="img_1" /> <source media="(min-width:465px)" srcset="img_2" /> <img src="img_3" /> </picture>