vikpe/php-html-heading-normalizer

PHP 类,用于标准化(提升/降低)HTML 标题

1.1.0 2017-01-29 14:45 UTC

This package is not auto-updated.

Last update: 2024-09-28 20:03:45 UTC


README

PHP 类,用于标准化(提升/降低)HTML 标题。

Build Status Test Coverage Code Climate Scrutinizer Code Quality StyleCI

安装

composer require vikpe/php-html-heading-normalizer

方法

promote(string $html, int $numberOfLevels)

$html 中的所有标题提升 $numberOfLevels 级别。

\Vikpe\HtmlHeadingNormalizer::promote('<h6>Foo</h6>', 3); // '<h3>Foo</h3>'

demote(string $html, int $numberOfLevels)

$html 中的所有标题降低 $numberOfLevels 级别。

\Vikpe\HtmlHeadingNormalizer::demote('<h1>Foo</h1>', 1); // '<h2>Foo</h2>'

min(string $html, int $minLevel)

提升/降低 $html 中的所有标题,以便最低标题级别等于 $minLevel

\Vikpe\HtmlHeadingNormalizer::min('<h4>Foo</h4><h5>Bar</h5>', 1); // '<h1>Foo</h1><h2>Bar</h2>'