aozen/prism2torchlight

Laravel 包,用于无缝将 PrismJS HTML 代码块转换为 Torchlight 语法高亮。

v1.0.0 2023-12-03 23:19 UTC

This package is auto-updated.

Last update: 2024-09-04 00:52:14 UTC


README

Prism2Torchlight 是一个 Laravel 包,旨在轻松将 PrismJS HTML 代码块转换为 Torchlight 语法高亮。

安装

您可以通过 Composer 安装此包

composer require aozen/prism2torchlight

使用方法

要使用 Prism2Torchlight,您需要在 Eloquent 模型的 $casts 属性中包含 TorchlightCast 类。这样,在从数据库检索数据时,将自动转换 PrismJS 代码块。

use Aozen\Prism2Torchlight\TorchlightCast;

class YourModel extends Model
{
    protected $casts = [
        'text' => TorchlightCast::class,
    ];
}

示例

$text = '<pre class="language-php"><code>echo "Hello, Laravel!";</code></pre>';
$convertedText = Prism2Torchlight\Prism2Torchlight::convertToTorchlight($text);

echo $convertedText;

要求

  1. PHP >= 7.3
  2. Laravel >= 7.0

许可

此包是开源软件,许可协议为 MIT 协议。请随意将此内容复制粘贴到您的 README.md 文件中。如果您有其他请求或修改意见,请告诉我!