protected String extractLink(final CharacterIterator ci){
  final StringBuilder sbuf=new StringBuilder();
  char ch=ci.current();
  char terminator=' ';
  if (ch == '\'') {
    terminator=ch;
  }
  while (ch != CharacterIterator.DONE) {
    if (ch == terminator) {
      if (terminator == ' ') {
        ch=ci.next();
        if (ch == '#') {
          ch=' ';
        }
 else {
          ci.previous();
          break;
        }
      }
 else {
        break;
      }
    }
    sbuf.append(ch);
    ch=ci.next();
  }
  int len=sbuf.length();
  while (len != 0) {
    if (!isWordDelim(sbuf.charAt(--len))) {
      len++;
      break;
    }
    sbuf.setLength(len);
    ci.previous();
  }
  if (len == 0) {
    return null;
  }
  return sbuf.toString();
}

protected String extractLink ( final CharacterIterator ci ) { final StringBuilder sbuf = new StringBuilder ( ) ; char ch = ci . current ( ) ; char terminator = ' ' ; if ( ch == '\'' ) { terminator = ch ; } while ( ch != CharacterIterator . DONE ) { if ( ch == terminator ) { if ( terminator == ' ' ) { ch = ci . next ( ) ; if ( ch == '#' ) { ch = ' ' ; } else { ci . previous ( ) ; break ; } } else { break ; } } sbuf . append ( ch ) ; ch = ci . next ( ) ; } int len = sbuf . length ( ) ; while ( len != 0 ) { if ( ! isWordDelim ( sbuf . charAt ( -- len ) ) ) { len ++ ; break ; } sbuf . setLength ( len ) ; ci . previous ( ) ; } if ( len == 0 ) { return null ; } return sbuf . toString ( ) ; }
extract link content from a character iterator . it is assumed that the ' # ' has already been eaten . it leaves the character iterator at the first character after the link text .
