How to use parse-entities - 6 common examples

To help you get started, we’ve selected a few parse-entities examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mosjs / mos / packages / mos-core / src / stringify / entity-prefix-length.ts View on Github external
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
}
github mosjs / mos / packages / mos-core / src / parse / inline-tokenizers / url.ts View on Github external
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)
  )
}
github orbiting / mdast / packages / remark-preset / src / span.js View on Github external
dataAttrs.forEach(d => {
      const [key, value] = d.split('=')
      data[
        decodeEntities(key.replace(/^data-/, ''))
      ] = decodeEntities(value.slice(1, -1))
    })
    return {
github orbiting / mdast / packages / remark-preset / src / span.js View on Github external
dataAttrs.forEach(d => {
      const [key, value] = d.split('=')
      data[
        decodeEntities(key.replace(/^data-/, ''))
      ] = decodeEntities(value.slice(1, -1))
    })
    return {
github mosjs / mos / packages / mos-core / src / parse / inline-tokenizers / auto-link.ts View on Github external
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
    })
}
github mosjs / mos / packages / mos-core / src / parse / index.ts View on Github external
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,
    })
  }, {
    /**

parse-entities

Parse HTML character references

MIT
Latest version published 2 years ago

Package Health Score

65 / 100
Full package analysis

Popular parse-entities functions