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

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

package fitnesse.wikitext.parser;

import fitnesse.wikitext.shared.ToHtml;

import java.util.List;

public class AnchorName extends SymbolType implements Rule {

    public AnchorName() {
        super("AnchorName");
        wikiMatcher(new Matcher().string("!anchor"));
        wikiRule(this);
        htmlTranslation(Translate.with(ToHtml::anchorName).child(0));
    }

    @Override
    public Maybe parse(Symbol current, Parser parser) {
        List tokens = parser.moveNext(new SymbolType[] {SymbolType.Whitespace, SymbolType.Text});
        if (tokens.isEmpty()) return Symbol.nothing;

        String anchor = tokens.get(1).getContent();
        if (!ScanString.isWord(anchor)) return Symbol.nothing;

        current.add(tokens.get(1));
        return new Maybe<>(current);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy