ueberdosis/commonmark-hint-extension

league/commonmark 的提示扩展

0.1.0 2021-08-26 11:50 UTC

This package is auto-updated.

Last update: 2024-08-27 22:18:50 UTC


README

我们需要您的支持来维护此包。💖 https://github.com/sponsors/ueberdosis

CommonMark 提示扩展

Tests Sponsor

league/commonmark 的提示扩展,可以将以下 Markdown 渲染成 HTML。

示例

Markdown

:::important Warning!
This is how the **Markdown** looks.
:::

HTML

<div class="hint important">
    <h2 class="hint-title">
        Warning!
    </h2>
    <p class="hint-content">
        This is how the <strong>Markdown</strong> looks.
    </p>
</div>

安装

您可以通过 composer 安装此包

composer require ueberdosis/commonmark-hint-extension

用法

<?php

use League\CommonMark\Environment\Environment;
use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
use League\CommonMark\MarkdownConverter;
use Ueberdosis\CommonMark\HintExtension;

// Configure the Environment with all the CommonMark parsers/renderers
$environment = new Environment();
$environment->addExtension(new CommonMarkCoreExtension());

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

// Instantiate the converter engine and start converting some Markdown!
$converter = new MarkdownConverter($environment);
$markdown = <<<MARKDOWN
:::important Warning!
This is how the **Markdown** looks.
:::
MARKDOWN;

echo $converter->convertToHtml($markdown);

测试

composer test

致谢

许可

MIT 许可证 (MIT)。请参阅 许可文件 获取更多信息。