Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function entityPrefixLength (value: string): number {
/* istanbul ignore if - Currently also tested for at
* implemention, but we keep it here because that’s
* proper. */
if (value.charAt(0) !== '&') {
return 0
}
const prefix = value.split('&', 2).join('&')
return prefix.length - decode(prefix).length
}
if (position === -1 || position === value.length - 1) {
return false
}
content = content.substr(MAILTO_PROTOCOL.length)
}
/* istanbul ignore if - never used (yet) */
if (silent) {
return true
}
const now = parser.eat.now()
return parser.eat(subvalue)(
renderLink(parser, decode(subvalue), content, null, now)
)
}
dataAttrs.forEach(d => {
const [key, value] = d.split('=')
data[
decodeEntities(key.replace(/^data-/, ''))
] = decodeEntities(value.slice(1, -1))
})
return {
dataAttrs.forEach(d => {
const [key, value] = d.split('=')
data[
decodeEntities(key.replace(/^data-/, ''))
] = decodeEntities(value.slice(1, -1))
})
return {
if (hasAtCharacter) {
if (
link.substr(0, MAILTO_PROTOCOL.length).toLowerCase() !== MAILTO_PROTOCOL
) {
link = MAILTO_PROTOCOL + link
} else {
content = content.substr(MAILTO_PROTOCOL.length)
now.column += MAILTO_PROTOCOL.length
now.offset += MAILTO_PROTOCOL.length
}
}
parser.context.inAutoLink = true
const eater = parser.eat(subvalue)
return renderLink(parser, decode(link), content, null, now)
.then(node => {
parser.context.inAutoLink = false
const addedNode = eater(node)
return addedNode
})
}
const decoder: Decoder = Object.assign(function (value: string, position: Location, handler: Function): void {
decode(value, {
position: normalize(position),
warning: handleWarning,
text: handler,
reference: handler,
textContext: context,
referenceContext: context,
})
}, {
/**