定制 ueberdosis/commonmark-embed-extension 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ueberdosis/commonmark-embed-extension

最新稳定版本:0.2.1

Composer 安装命令:

composer require ueberdosis/commonmark-embed-extension

包简介

An embed extension for league/commonmark

README 文档

README

We need your support to maintain this package. 💖 https://github.com/sponsors/ueberdosis

CommonMark Embed Extension

Tests Sponsor

An extension to transform URLs to embeds with league/commonmark.

Example

Markdown

OMG, you should see this video:

https://www.youtube.com/watch?v=eX2qFMC8cFo

It‘s amazing, isn’t it?

HTML

<p>OMG, you should see this video:</p>

<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/eX2qFMC8cFo" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>

<p>It‘s amazing, isn’t it?</p>

Installation

You can install the package via composer:

composer require ueberdosis/commonmark-embed-extension

Supported services

  • YouTube
  • Vimeo

Have a look at the provided services to learn how you can add your own integrations. Don’t forget to send a PR with your additions!

Usage

<?php

use League\CommonMark\Environment\Environment;
use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
use League\CommonMark\MarkdownConverter;
use Ueberdosis\CommonMark\EmbedExtension;
use Ueberdosis\CommonMark\Tests\Services\YouTube;
use Ueberdosis\CommonMark\Tests\Services\Vimeo;

// Configure the Environment with all the CommonMark parsers/renderers
$environment = new Environment([
    'embeds' => [
        new YouTube(),
        new Vimeo(),
    ],
]);
$environment->addExtension(new CommonMarkCoreExtension());

// Add this extension
$environment->addExtension(new EmbedExtension());

// Instantiate the converter engine and start converting some Markdown!
$converter = new MarkdownConverter($environment);
$markdown = <<<MARKDOWN
https://www.youtube.com/watch?v=eX2qFMC8cFo
MARKDOWN;

echo $converter->convertToHtml($markdown);

Testing

composer test

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 1.83k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-10-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固