gijserenstein/html-index-generator

appends id's to certain selected tags in a html string and exports a list of id's + names to create index anchor links on a page

dev-master 2020-05-24 12:45 UTC

This package is auto-updated.

Last update: 2025-06-25 01:05:32 UTC


README

#HTML index generator

For creating index anchor links to a piece of html.

Installation

composer require gijserenstein/html-index-generator

Usage

$someHtmlString = "<h1>BeepBoop</h1><h2>beep</h2><p>beepbeep</p><h2>boop</h2><p>beepboop</p>";

$indexGenerator = new HtmlIndexGenerator($someHtmlString, "h2", "article-");

$newHtmlString = $indexGenerator->getHtmlWithIndexedIds(); // The new html has id's added to the h2 tags

$indexItems = $indexHenerator->getIndexItems();