"Lazily" finds the link to use for a sassdoc. It attempts to match the `lastLink`,
but otherwise searches the `LINKS` for a match.

@param {String} ref - the ref to match with
@return {String} link - the link to use for the ref.
765182
function findLink(ref) {
  if (lastLink.indexOf(ref) !== -1) {
    return lastLink;
  }

  lastLink = '';
  routes.some((link) => {
    if (link.indexOf(ref) !== -1) {
      lastLink = link;
    }

    return lastLink;
  });

  return lastLink;
}
642950
function checkEnterOnSearch(e,refs){var val=e.target.value;if(val&&val!==''){var res=[];var selected=this.getSelected();var matches=this.search.isThereAnythingRelatedTo(val);matches.forEach(function(el){var index=el.i;el=refs.selectOptions[index];if(selected.indexOf(el)===-1){res.push(el);}});// If only one result is available, select that result.
// If more than one results, select one only on exact match.
var selectedIndex=-1;if(res.length===1){selectedIndex=0;}else if(res.length>1){for(var i=0;i<res.length;i++){if(res[i].text.toUpperCase()===val.toUpperCase()){selectedIndex=i;break;}}}if(selectedIndex!=-1){var el=res[selectedIndex];if(!el.disabled){this.setByIndex(el.index,this.multiple);if(this.multipleTags){setTimeout(function(){return refs.search.focus();},200);}if(this.onChange){try{this.onChange(e,this.getSelectedValues());}catch(e){console.warn('something may be wrong in "onChange"',e);}}}}return res;}return false;}
378951
function resolveLink(path) {
  var links = readLinkRecursive(path);
  var resolved = p.resolve.apply(null, links);

  trace('links', links, 'resolves to', resolved);

  return resolved;
}
259365
function _getRef (refOrQuery) {
  if (typeof refOrQuery.ref === 'function') {
    refOrQuery = refOrQuery.ref()
  } else if (typeof refOrQuery.ref === 'object') {
    refOrQuery = refOrQuery.ref
  }

  return refOrQuery
}
1000877
def match_ref(self, ref):
        
        if ref in self.refs:
            self._matched_ref = ref
            return True
        return False
783015
def visit_target(self, node):
        
        if self.lastref is None:
            return
        if (
            self.lastref.attributes['name'].lower() not in
            node.attributes['names'] and
            self.lastref.attributes['name'].lower() not in
            node.attributes['dupnames']
        ):
            # return if target doesn't match last reference found
            return
        if node.attributes['refuri'] not in self.replacements:
            # return if the refuri isn't in our replacement mapping
            return
        # ok, we have a node to replace...
        params = self.replacements[node.attributes['refuri']]
        meth = params[0]
        args = params[1:]
        # remove the target itself; we'll just replace the reference
        node.parent.remove(node)
        self.lastref.parent.replace(self.lastref, meth(*args))
525218
function nest (str, refs, escape) {
		var res = [], match

		var a = 0
		while (match = re.exec(str)) {
			if (a++ > 10e3) throw Error('Circular references in parenthesis')

			res.push(str.slice(0, match.index))

			res.push(nest(refs[match[1]], refs))

			str = str.slice(match.index + match[0].length)
		}

		res.push(str)

		return res
	}
644143
function reference(node) {
  var definition = this.definitions(node.identifier)
  return link.call(this, node, definition ? definition.url : null)
}
1274496
function getSortedRefPaths (reverse) {
  let refs = []

  if (this.schema.refs) {
    for (const key in this.schema.refs) {
      if (this.schema.refs.hasOwnProperty(key)) {
        refs.push(this.schema.refs[key].path)
      }
    }

    if (refs.length > 0) {
      refs = _.sortBy(refs, 'length')
      if (reverse) {
        refs.reverse()
      }
    }
  }

  return refs
}
1047023
function getReference($table, $ref = null) {
		if (isset($this->references[$table])) {
			if (!strlen($ref)) {
				return current($this->references[$table]);
			}
			if (isset($this->references[$table][$ref])) {
				return $this->references[$table][$ref];
			}
		}
	}
811710
function NavLink({
  "aria-current": ariaCurrent = "page",
  activeClassName = "active",
  activeStyle,
  className: classNameProp,
  exact,
  isActive: isActiveProp,
  location,
  strict,
  style: styleProp,
  to,
  ...rest
}) {
  const path = typeof to === "object" ? to.pathname : to;

  // Regex taken from: https://github.com/pillarjs/path-to-regexp/blob/master/index.js#L202
  const escapedPath = path && path.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1");

  return (
    <Route
      path={escapedPath}
      exact={exact}
      strict={strict}
      location={location}
      children={({ location, match }) => {
        const isActive = !!(isActiveProp
          ? isActiveProp(match, location)
          : match);

        const className = isActive
          ? joinClassnames(classNameProp, activeClassName)
          : classNameProp;
        const style = isActive ? { ...styleProp, ...activeStyle } : styleProp;

        return (
          <Link
            aria-current={(isActive && ariaCurrent) || null}
            className={className}
            style={style}
            to={to}
            {...rest}
          />
        );
      }}
    />
  );
}
191833
private String unexternalizeImageRef(String ref) {
    String unexternalizedRef = ref;

    if (StringUtils.isNotEmpty(unexternalizedRef)) {

      // decode if required
      unexternalizedRef = decodeIfEncoded(unexternalizedRef);

      // TODO: implementation has to be aligned with MediaSource implementations!
      // remove default servlet extension that is needed for inline images in RTE
      unexternalizedRef = StringUtils.removeEnd(unexternalizedRef, "/" + JcrConstants.JCR_CONTENT + ".default");
      unexternalizedRef = StringUtils.removeEnd(unexternalizedRef, "/_jcr_content.default");
    }

    return unexternalizedRef;
  }
866398
def get_stack_refs(refs: list):  # copy pasted from Senza
    
    refs = list(refs)
    refs.reverse()
    stack_refs = []
    last_stack = None
    while refs:
        ref = refs.pop()
        if last_stack is not None and re.compile(r'v[0-9][a-zA-Z0-9-]*$').match(ref):
            stack_refs.append(StackReference(last_stack, ref))
        else:
            try:
                with open(ref) as fd:
                    data = yaml.safe_load(fd)
                ref = data['SenzaInfo']['StackName']
            except (OSError, IOError):
                # It's still possible that the ref is a regex
                pass

            if refs:
                version = refs.pop()
            else:
                version = None
            stack_refs.append(StackReference(ref, version))
            last_stack = ref
    return stack_refs
90198
def findFirstHref(link_attrs_list, target_rel):
    """"""
    # XXX: TESTME
    matches = findLinksRel(link_attrs_list, target_rel)
    if not matches:
        return None
    first = matches[0]
    return first.get('href')
879255
function collectRefs() {
  // check if there's a shadow root in the element
  if (typeof this.shadowRoot === 'undefined') {
    throw new Error('You must create a shadowRoot on the element');
  }

  // create refs base object
  this.refs = {};

  var refsList = this.shadowRoot.querySelectorAll('[ref]');

  // collect refs if any
  if (refsList.length > 0) {
    var refsArray = _toArray(refsList);

    refsArray.map(_assignRef.bind(this));
  }

  // observe added and removed child nodes
  var refsMutationObserver = new MutationObserver(_handleMutations.bind(this));

  refsMutationObserver.observe(this.shadowRoot, {
    childList: true,
    subtree: true
  });
}
1098912
private function parseRefAsCommit($reference): ?string
    {
        if (preg_match(self::REGEX_COMMIT, $reference, $matches) !== 1) {
            return null;
        }

        return $matches[0];
    }
276576
function(left, right) {
    var ref = findReference(left, right);
    if (!ref) {
      ref = findReference(right, left);
    }
    return left.join(right).on(ref.left.equals(ref.right));
  }