PHP class for normalizing (promote/demote) HTML headings.
composer require vikpe/php-html-heading-normalizer
Promotes all headings in $html
by $numberOfLevels
levels.
\Vikpe\HtmlHeadingNormalizer::promote('<h6>Foo</h6>', 3); // '<h3>Foo</h3>'
Demotes all headings in $html
by $numberOfLevels
levels.
\Vikpe\HtmlHeadingNormalizer::demote('<h1>Foo</h1>', 1); // '<h2>Foo</h2>'
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>'