public final static int readMdLinkId(final StringBuilder out,final String in,final int start){
  int pos=start;
  int counter=1;
  while (pos < in.length()) {
    final char ch=in.charAt(pos);
    boolean endReached=false;
switch (ch) {
case '\n':
      out.append(' ');
    break;
case '[':
  counter++;
out.append(ch);
break;
case ']':
counter--;
if (counter == 0) {
endReached=true;
}
 else {
out.append(ch);
}
break;
default :
out.append(ch);
break;
}
if (endReached) {
break;
}
pos++;
}
return (pos == in.length()) ? -1 : pos;
}

public final static int readMdLinkId ( final StringBuilder out , final String in , final int start ) { int pos = start ; int counter = 1 ; while ( pos < in . length ( ) ) { final char ch = in . charAt ( pos ) ; boolean endReached = false ; switch ( ch ) { case '\n' : out . append ( ' ' ) ; break ; case '[' : counter ++ ; out . append ( ch ) ; break ; case ']' : counter -- ; if ( counter == 0 ) { endReached = true ; } else { out . append ( ch ) ; } break ; default : out . append ( ch ) ; break ; } if ( endReached ) { break ; } pos ++ ; } return ( pos == in . length ( ) ) ? - 1 : pos ; }
reads a markdown link id .
