index.js
function ellipses(node, index, parent) {
  var value = node.value
  var siblings = parent.children
  var position
  var nodes
  var sibling
  var type
  var count
  var queue

  // Simple node with three dots and without white-space.
  if (threeFullStopsExpression.test(node.value)) {
    node.value = ellipsis
    return
  }

  if (!fullStopsExpression.test(value)) {
    return
  }

  // Search for dot-nodes with white-space between.
  nodes = []
  position = index
  count = 1

  // It’s possible that the node is merged with an adjacent word-node.  In that
  // code, we cannot transform it because there’s no reference to the
  // grandparent.
  while (--position > 0) {
    sibling = siblings[position]

    if (sibling.type !== whiteSpace) {
      break
    }

    queue = sibling
    sibling = siblings[--position]
    type = sibling && sibling.type

    if (
      sibling &&
      (type === punctuation || type === symbol) &&
      fullStopsExpression.test(sibling.value)
    ) {
      nodes.push(queue, sibling)

      count++

      continue
    }

    break
  }

  if (count < 3) {
    return
  }

  siblings.splice(index - nodes.length, nodes.length)

  node.value = ellipsis
}
function ellipses(node, index, parent) {
  var value = node.value
  var siblings = parent.children
  var position
  var nodes
  var sibling
  var type
  var count
  var queue

  // Simple node with three dots and without white-space.
  if (threeFullStopsExpression.test(node.value)) {
    node.value = ellipsis
    return
  }

  if (!fullStopsExpression.test(value)) {
    return
  }

  // Search for dot-nodes with white-space between.
  nodes = []
  position = index
  count = 1

  // It’s possible that the node is merged with an adjacent word-node.  In that
  // code, we cannot transform it because there’s no reference to the
  // grandparent.
  while (--position > 0) {
    sibling = siblings[position]

    if (sibling.type !== whiteSpace) {
      break
    }

    queue = sibling
    sibling = siblings[--position]
    type = sibling && sibling.type

    if (
      sibling &&
      (type === punctuation || type === symbol) &&
      fullStopsExpression.test(sibling.value)
    ) {
      nodes.push(queue, sibling)

      count++

      continue
    }

    break
  }

  if (count < 3) {
    return
  }

  siblings.splice(index - nodes.length, nodes.length)

  node.value = ellipsis
}
function ellipses ( node , index , parent ) { var value = node . value var siblings = parent . children var position var nodes var sibling var type var count var queue // Simple node with three dots and without white-space. if ( threeFullStopsExpression . test ( node . value ) ) { node . value = ellipsis return } if ( ! fullStopsExpression . test ( value ) ) { return } // Search for dot-nodes with white-space between. nodes = [ ] position = index count = 1 // It’s possible that the node is merged with an adjacent word-node.  In that // code, we cannot transform it because there’s no reference to the // grandparent. while ( -- position > 0 ) { sibling = siblings [ position ] if ( sibling . type !== whiteSpace ) { break } queue = sibling sibling = siblings [ -- position ] type = sibling && sibling . type if ( sibling && ( type === punctuation || type === symbol ) && fullStopsExpression . test ( sibling . value ) ) { nodes . push ( queue , sibling ) count ++ continue } break } if ( count < 3 ) { return } siblings . splice ( index - nodes . length , nodes . length ) node . value = ellipsis }
Transform multiple dots into unicode ellipses.
Transform multiple dots into unicode ellipses .