All Downloads are FREE. Search and download functionalities are using the official Maven repository.

fitnesse.wikitext.parser.StyleRule Maven / Gradle / Ivy

There is a newer version: 20181217
Show newest version
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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy