vikpe / php-html-heading-normalizer

PHP class for normalizing (promote/demote) HTML headings

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PHP: HTML Heading Normalizer

PHP class for normalizing (promote/demote) HTML headings.

Build Status Test Coverage Code Climate Scrutinizer Code Quality StyleCI

Installation

composer require vikpe/php-html-heading-normalizer

Methods

promote(string $html, int $numberOfLevels)

Promotes all headings in $html by $numberOfLevels levels.

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

demote(string $html, int $numberOfLevels)

Demotes all headings in $html by $numberOfLevels levels.

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

min(string $html, int $minLevel)

Promotes/demotes all headings in $html so that the lowest heading level equals $minLevel.

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

About

PHP class for normalizing (promote/demote) HTML headings

License:MIT License


Languages

Language:PHP 88.2%Language:HTML 11.8%