node_modules/remark/node_modules/remark-stringify/lib/util/copy-identifier-encoding.js
/**
 * For shortcut and collapsed reference links, the contents
 * is also an identifier, so we need to restore the original
 * encoding and escaping that were present in the source
 * string.
 *
 * This function takes the unescaped & unencoded value from
 * shortcut's child nodes and the identifier and encodes
 * the former according to the latter.
 *
 * @example
 *   copyIdentifierEncoding('a*b', 'a\\*b*c')
 *   // 'a\\*b*c'
 *
 * @param {string} value - Unescaped and unencoded stringified
 *   link value.
 * @param {string} identifier - Link identifier.
 * @return {string} - Encoded link value.
 */
For shortcut and collapsed reference links, the contents
is also an identifier, so we need to restore the original
encoding and escaping that were present in the source
string.

This function takes the unescaped & unencoded value from
shortcut's child nodes and the identifier and encodes
the former according to the latter.



@param {string} value - Unescaped and unencoded stringified
link value.
@param {string} identifier - Link identifier.
@return {string} - Encoded link value.
For shortcut and collapsed reference links the contents is also an identifier so we need to restore the original encoding and escaping that were present in the source string . This function takes the unescaped & unencoded value from shortcut ' s child nodes and the identifier and encodes the former according to the latter . @param { string } value - Unescaped and unencoded stringified link value . @param { string } identifier - Link identifier . @return { string } - Encoded link value .
function copy(value, identifier) {
  var length = value.length;
  var count = identifier.length;
  var result = [];
  var position = 0;
  var index = 0;
  var start;
  while (index < length) {
    start = index;
    while (index < length && !PUNCTUATION.test(value.charAt(index))) {
      index += 1;
    }
    result.push(value.slice(start, index));
    while (position < count && !PUNCTUATION.test(identifier.charAt(position))) {
      position += 1;
    }
    start = position;
    while (position < count && PUNCTUATION.test(identifier.charAt(position))) {
      if (identifier.charAt(position) === '&') {
        position += entityPrefixLength(identifier.slice(position));
      }
      position += 1;
    }
    result.push(identifier.slice(start, position));
    while (index < length && PUNCTUATION.test(value.charAt(index))) {
      index += 1;
    }
  }
  return result.join('');
}
function copy ( value , identifier ) { var length = value . length ; var count = identifier . length ; var result = [ ] ; var position = 0 ; var index = 0 ; var start ; while ( index < length ) { start = index ; while ( index < length && ! PUNCTUATION . test ( value . charAt ( index ) ) ) { index += 1 ; } result . push ( value . slice ( start , index ) ) ; while ( position < count && ! PUNCTUATION . test ( identifier . charAt ( position ) ) ) { position += 1 ; } start = position ; while ( position < count && PUNCTUATION . test ( identifier . charAt ( position ) ) ) { if ( identifier . charAt ( position ) === '&' ) { position += entityPrefixLength ( identifier . slice ( position ) ) ; } position += 1 ; } result . push ( identifier . slice ( start , position ) ) ; while ( index < length && PUNCTUATION . test ( value . charAt ( index ) ) ) { index += 1 ; } } return result . join ( '' ) ; }
For shortcut and collapsed reference links, the contents
 is also an identifier, so we need to restore the original
 encoding and escaping that were present in the source
 string.
For shortcut and collapsed reference links the contents is also an identifier so we need to restore the original encoding and escaping that were present in the source string .
/* Take next non-punctuation characters from `value`. */ /* Advance `position` to the next punctuation character. */ /* Take next punctuation characters from `identifier`. */ /* Advance `index` to the next non-punctuation character. */