vikpe / php-html-heading-normalizer
PHP class for normalizing (promote/demote) HTML headings
Installs: 5 774
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=5.3.0
Requires (Dev)
- codeclimate/php-test-reporter: ~0.4.1
- phpunit/phpunit: ~4.0
This package is not auto-updated.
Last update: 2024-04-13 17:35:44 UTC
README
PHP class for normalizing (promote/demote) HTML headings.
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>'