Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return this.getAnchorHeadings(html).reduce((result, item) => {
// Ignore empty headings.
if (this.textExists(item.text)) {
result.push({
text: item.text,
url: '#' + getAnchorLinkName(item.text)
})
}
return result
}, [])
},
titleId () {
if (this.title) {
return getAnchorLinkName(this.title)
}
}
},
this.page.appDComponents.forEach(component => {
if (component && component.name && component.data) {
switch (component.name) {
case 'rpl-markup':
if (component.data.html) {
anchors.push(...anchorUtils.getAnchorLinks(component.data.html))
}
break
case 'rpl-accordion':
if (component.data.title) {
anchors.push({ text: component.data.title, url: `#${getAnchorLinkName(component.data.title)}` })
}
break
}
}
})
return anchors
this.find('h2').map((i, element) => {
const el = this.find(element)
const idName = el.text()
return el.attr('id', getAnchorLinkName(idName))
})
}
this.getAnchorHeadings(html).forEach(item => {
const newAnchor = this.textExists(item.text) ? ` id="${getAnchorLinkName(item.text)}"` : ''
const headingIndex = item.indexStart + offset + headingTagOffset
newHTML = newHTML.slice(0, headingIndex) + newAnchor + newHTML.slice(headingIndex)
offset += newAnchor.length
})
return newHTML