mzdr / oh-snap

此包已被弃用且不再维护。未建议替代包。

BooBoo 的一个漂亮的格式化工具。

安装: 80

依赖项: 2

建议者: 0

安全: 0

星标: 1

关注者: 1

分支: 0

开放问题: 0

语言:CSS

1.0.0 2018-05-01 12:24 UTC

This package is auto-updated.

Last update: 2021-04-16 20:02:20 UTC


README

Screenshot

💥 Oh Snap!

BooBoo 的一个漂亮的格式化工具。



安装

建议您使用 Composer 安装此库。

composer require mzdr/oh-snap

别忘了查看 BooBoo 的官方文档,了解如何使用和安装它。


使用

<?php

require __DIR__ . '/vendor/autoload.php';

use League\BooBoo\BooBoo;
use mzdr\OhSnap\Formatter\PrettyFormatter;

// Options array for adjusting formatter behaviour.
// Default values are shown below.
$options = [

    // List of CSS files to include in the (default) template.
    'theme' => ['default'],

    // Path to custom template file.
    'template' => null,

    // If set to true, code preview will not contain the
    // whole file but the amount of lines defined in excerptSize.
    'excerptOnly' => false,

    // Amount of lines the code preview should have…
    'excerptSize' => 20,

    // Optional header/footer content to show. May be a path
    // to a file that should be required. Output will not be
    // sanitized in any way.
    'header' => null,
    'footer' => null
];

$booboo = new BooBoo([new PrettyFormatter($options)]);
$booboo->register();

throw new RuntimeException('Oh snap! 🙈');

定制

您可以通过三种不同的方式来定制格式化工具。


完全 🤓

如果您想完全控制格式化工具的输出,您可能需要使用自定义模板。这最好是一个 .php 文件,因为它将被 require() 并返回给 BooBoo。

请记住,如果您这样做,您将从零开始。查看 默认模板 以获得灵感。 🌟


部分 💄

如果您只是想重新绘制默认模板,这是可行的。您可以使用一个全新的 CSS 文件 或者 添加一个。

<?php

$options = [

    // Building on top of default styles…
    'theme' => ['default', 'path/to/your.css', 'a { color: pink; }'],

    // Using different stylesheet…
    'theme' => ['path/to/your.css'],

    // Using no styles at all? ¯\_(ツ)_/¯
    'theme' => [],
];


略微 ✍️

也许 header 和/或 footer 选项就足够了?它们将被放置在默认模板的相应元素(例如 <header class="header-panel"><?= $header ?></header>)内 或者 如果您实现了它,您的自定义模板内。您可以传递任何您喜欢的字符串,包括 HTML。非常适合进行一点品牌推广。


许可证

此项目采用 MIT 许可证