code: function(s, refmap) {
    this.subject = s;
    this.pos = 0;
    var rawlabel;
    var dest;
    var title;
    var matchChars;
    var startpos = this.pos;
    var match;
  
    // label:
    matchChars = this.parseLinkLabel();
    if (matchChars === 0) {
      return 0;
    } else {
      rawlabel = this.subject.substr(0, matchChars);
    }
  
    // colon:
    if (this.peek() === ':') {
      this.pos++;
    } else {
      this.pos = startpos;
      return 0;
    }
  
    //  link url
    this.spnl();
  
    dest = this.parseLinkDestination();
    if (dest === null || dest.length === 0) {
      this.pos = startpos;
      return 0;
    }
  
    var beforetitle = this.pos;
    this.spnl();
    title = this.parseLinkTitle();
    if (title === null) {
      title = '';
      // rewind before spaces
      this.pos = beforetitle;
    }
  
    // make sure we're at line end:
    if (this.match(/^ *(?:\n|$)/) === null) {
      this.pos = startpos;
      return 0;
    }
  
    var normlabel = normalizeReference(rawlabel);
  
    if (!refmap[normlabel]) {
      refmap[normlabel] = { destination: dest, title: title };
    }
    return this.pos - startpos;
  }
docs: Attempt to parse a link reference, modifying refmap.