gijserenstein / html-index-generator
在HTML字符串中为某些选定的标签附加id,并将id列表和名称导出以创建页面上索引锚点的链接
dev-master
2020-05-24 12:45 UTC
Requires
- php: ^7.2
- ext-dom: *
- ext-libxml: *
This package is auto-updated.
Last update: 2024-09-24 23:05:59 UTC
README
#HTML索引生成器
用于创建指向HTML片段的索引锚点链接。
安装
composer require gijserenstein/html-index-generator
用法
$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();