/**
* Parse a base64 image URI into the data and extension.
*
- * @return array{extension: array, data: string}
+ * @return array{extension: string, data: string}
*/
protected function parseBase64ImageUri(string $uri): array
{
}
}
+ // Set ids on nested header nodes
+ $nestedHeaders = $xPath->query('//body//*//h1|//body//*//h2|//body//*//h3|//body//*//h4|//body//*//h5|//body//*//h6');
+ foreach ($nestedHeaders as $nestedHeader) {
+ [$oldId, $newId] = $this->setUniqueId($nestedHeader, $idMap);
+ if ($newId && $newId !== $oldId) {
+ $this->updateLinks($xPath, '#' . $oldId, '#' . $newId);
+ }
+ }
+
// Ensure no duplicate ids within child items
$idElems = $xPath->query('//body//*//*[@id]');
foreach ($idElems as $domElem) {
*/
protected function setUniqueId(\DOMNode $element, array &$idMap): array
{
- if (get_class($element) !== 'DOMElement') {
+ if (!$element instanceof \DOMElement) {
return ['', ''];
}
return [$existingId, $existingId];
}
- // Create an unique id for the element
+ // Create a unique id for the element
// Uses the content as a basis to ensure output is the same every time
// the same content is passed through.
$contentId = 'bkmrk-' . mb_substr(strtolower(preg_replace('/\s+/', '-', trim($element->nodeValue))), 0, 20);