private static String replaceReferences()

in markbook/src/main/java/org/apache/hadoop/gateway/markbook/MarkBook.java [137:148]


  private static String replaceReferences( String text ) throws IOException {
    Pattern pattern = Pattern.compile( "(\\s)#\\[(.+?)\\]" );
    Matcher matcher = pattern.matcher( text );
    while( matcher.find() ) {
      String space = matcher.group( 1 );
      String name = matcher.group( 2 ).trim();
      String id = id( name );
      text = replace( matcher, text, String.format( "%s[%s](#%s)", space, name, id ) );
      matcher = pattern.matcher( text );
    }
    return text;
  }