fitnesse.wikitext.parser.StyleRule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fitnesse Show documentation
Show all versions of fitnesse Show documentation
The fully integrated standalone wiki, and acceptance testing framework.
package fitnesse.wikitext.parser;
public class StyleRule implements Rule {
@Override
public Maybe parse(Symbol current, Parser parser) {
String content = current.getContent();
char beginner = content.charAt(content.length() - 1);
Symbol body = parser.parseToIgnoreFirst(closeType(beginner));
if (parser.atEnd()) return Symbol.nothing;
return new Maybe<>(new Symbol(SymbolType.Style, content.substring(7, content.length() - 1)).add(body));
}
private static SymbolType closeType(char beginner) {
return beginner == '[' ? SymbolType.CloseBracket
: beginner == '{' ? SymbolType.CloseBrace
: SymbolType.CloseParenthesis;
}
}