private static String replaceIncludes()

in markbook/src/main/java/org/apache/hadoop/gateway/markbook/MarkBook.java [104:120]


  private static String replaceIncludes( File file, String text ) throws IOException {
    Pattern pattern = Pattern.compile( "<<\\s*(.+?)\\s*>>" );
    Matcher matcher = pattern.matcher( text );
    while( matcher.find() ) {
      String includeFileName = matcher.group( 1 );
      File includeFile = new File( file.getParent(), includeFileName );
      if( includeFile.exists() && includeFile.canRead() ) {
        String includeString = loadMarkdown( includeFile );
        text = replace( matcher, text, includeString );
      } else {
        throw new FileNotFoundException( includeFile.getAbsolutePath() );
        //text = replace( matcher, text, includeFileName );
      }
      matcher = pattern.matcher( text );
    }
    return text;
  }