* @return
*/
private Template findRules( String word, String wikiText ) {
int idxStart = wikiText.indexOf( "{{{" );
int idxEnd = wikiText.indexOf( "}}}", idxStart );
Template template = generator.new Template(word);
while( idxStart >= 0 && idxEnd >= 0 ) {
String rule = wikiText.substring( idxStart+3, idxEnd );
//ignore cascading rules
boolean validRule = rule.length() > 0;
for(int i=0; i<rule.length(); i++){
char c = rule.charAt( i );
if(c != ' ' && !Character.isLetterOrDigit( c ) ){
validRule = false;
break;
}
}
if(validRule){
String ending = findEnding(wikiText, idxEnd+3);
if(ending.length() > 0){
template.addEnding( rule, ending );
}
}
idxStart = wikiText.indexOf( "{{{", idxEnd );
idxEnd = wikiText.indexOf( "}}}", idxStart );