docs: private int checkLink(final StringBuilder out, final String in, final int start, final MarkToken token)
      {
          boolean isAbbrev = false;
          int pos = start + (token == MarkToken.LINK ? 1 : 2);
          final StringBuilder temp = new StringBuilder();
  
          temp.setLength(0);
          pos = Utils.readMdLinkId(temp, in, pos);
          if (pos < start)
          {
              return -1;
          }
  
          final String name = temp.toString();
          String link = null, comment = null;
          final int oldPos = pos++;
          pos = Utils.skipSpaces(in, pos);
          if (pos < start)
          {
              final LinkRef lr = this.linkRefs.get(name.toLowerCase());
              if (lr != null)
              {
                  isAbbrev = lr.isAbbrev;
                  link = lr.link;
                  comment = lr.title;
                  pos = oldPos;
              }
              else
              {
                  return -1;
              }
          }
          else if (in.charAt(pos) == '(')
          {
              pos++;
              pos = Utils.skipSpaces(in, pos);
              if (pos < start)
              {
                  return -1;
              }
              temp.setLength(0);
              final boolean useLt = in.charAt(pos) == '<';
              pos = useLt ? Utils.readUntil(temp, in, pos + 1, '>') : Utils.readMdLink(temp, in, pos);
              if (pos < start)
              {
                  return -1;
              }
              if (useLt)
              {
                  pos++;
              }
              link = temp.toString();
  
              if (in.charAt(pos) == ' ')
              {
                  pos = Utils.skipSpaces(in, pos);
                  if (pos > start && in.charAt(pos) == '"')
                  {
                      pos++;
                      temp.setLength(0);
                      pos = Utils.readUntil(temp, in, pos, '"');
                      if (pos < start)
                      {
                          return -1;
                      }
                      comment = temp.toString();
                      pos++;
                      pos = Utils.skipSpaces(in, pos);
                      if (pos == -1)
                      {
                          return -1;
                      }
                  }
              }
              if (in.charAt(pos) != ')')
              {
                  return -1;
              }
          }
          else if (in.charAt(pos) == '[')
          {
              pos++;
              temp.setLength(0);
              pos = Utils.readRawUntil(temp, in, pos, ']');
              if (pos < start)
              {
                  return -1;
              }
              final String id = temp.length() > 0 ? temp.toString() : name;
              final LinkRef lr = this.linkRefs.get(id.toLowerCase());
              if (lr != null)
              {
                  link = lr.link;
                  comment = lr.title;
              }
          }
          else
          {
              final LinkRef lr = this.linkRefs.get(name.toLowerCase());
              if (lr != null)
              {
                  isAbbrev = lr.isAbbrev;
                  link = lr.link;
                  comment = lr.title;
                  pos = oldPos;
              }
              else
              {
                  return -1;
              }
          }
  
          if (link == null)
          {
              return -1;
          }
  
          if (token == MarkToken.LINK)
          {
              if (isAbbrev && comment != null)
              {
                  if (!this.useExtensions)
                  {
                      return -1;
                  }
                  out.append("<abbr title=\"");
                  Utils.appendValue(out, comment, 0, comment.length());
                  out.append("\">");
                  this.recursiveEmitLine(out, name, 0, MarkToken.NONE);
                  out.append("</abbr>");
              }
              else
              {
                  this.config.decorator.openLink(out);
                  out.append(" href=\"");
                  Utils.appendValue(out, link, 0, link.length());
                  out.append('"');
                  if (comment != null)
                  {
                      out.append(" title=\"");
                      Utils.appendValue(out, comment, 0, comment.length());
                      out.append('"');
                  }
                  out.append('>');
                  this.recursiveEmitLine(out, name, 0, MarkToken.NONE);
                  this.config.decorator.closeLink(out);
              }
          }
          else
          {
              this.config.decorator.openImage(out);
              out.append(" src=\"");
              Utils.appendValue(out, link, 0, link.length());
              out.append("\" alt=\"");
              Utils.appendValue(out, name, 0, name.length());
              out.append('"');
              if (comment != null)
              {
                  out.append(" title=\"");
                  Utils.appendValue(out, comment, 0, comment.length());
                  out.append('"');
              }
              this.config.decorator.closeImage(out);
          }
  
          return pos;
      }