surface / commonmark-ext-spotify-iframe
Extension for league/commonmark to replace Spotify link with an iframe.
Installs: 2 239
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:commonmark-extension
Requires
- php: ^8.0
- league/commonmark: ^2.3
Requires (Dev)
- phpmd/phpmd: ^2.12
- phpro/grumphp: ^1.5
- phpstan/phpstan: ^1.5
- phpunit/phpunit: ^9.5
- sirbrillig/phpcs-import-detection: ^1.3
- slevomat/coding-standard: ^7.1
- squizlabs/php_codesniffer: ^3.6
README
An extension for league/commonmark version 2 built using PHP 8.0. This replaces Spotify links with the embed iframe.
The extension supports for tracks, artists, albums and playlists using the embed URL format.
Initially based on the YouTube extension.
Installation
The project should be installed via Composer:
composer require surface/commonmark-ext-spotify-iframe
Usage
Configure your CommonMark Environment
and add the extension.
use League\CommonMark\Environment\Environment; use League\CommonMark\MarkdownConverter as Converter; use Surface\CommonMark\Ext\SpotifyIframe\Extension as SpotifyExtension; $options = [ 'spotify_iframe' => [ 'size' => 'large', ], ]; $environment = new Environment($options); $environment->addExtension(new SpotifyExtension()); $converter = new Converter($environment); echo $converter->convert('[](https://open.spotify.com/embed/artist/xxx)'); echo $converter->convert('[](https://open.spotify.com/embed/track/xxx?theme=0)'); echo $converter->convert('[](https://open.spotify.com/embed/album/xxx?theme=1&size=small)'); echo $converter->convert('[](https://open.spotify.com/embed/playlist/xxx?theme=1&size=lg)');
Sizes
Spotify provides two different sizes, large
and small
. By default the
extension provides the large
version. You can configure the option globally
using the size
option.
You can also configure the size option using a query parameter on the embed
URL. The supported sizes are large
, lg
, small
and sm
.
?size=large ?size=small ?size=lg ?size=sm
Testing
There are Unit and Integration tests for the project. These can be run using the following commands:
composer test composer run test composer run test-unit composer run test-integration
There are also scripts to run code sniffer, mess detector and static analysis:
composer run sniff composer run mess composer run stan
Changelog
Please refer to the CHANGELOG for more information on what has changed recently.
License
This library is licensed under the MIT license. See the License File for more information.