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

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

There is a newer version: 20241026
Show newest version
package fitnesse.wikitext.parser;

import fitnesse.wikitext.SourcePage;

import java.util.HashMap;
import java.util.Map;

public class WikiTranslator extends Translator {
    private static final Map translations;

    static {
        translations = new HashMap<>();
        addTranslation(Alias.symbolType, new WikiBuilder().text("[[").children("][").text("]]"));
        addTranslation(Link.symbolType, new WikiBuilder().content().child(0));
        addTranslation(Literal.symbolType, new WikiBuilder().text("!-").content().text("-!"));
        addTranslation(Path.symbolType, new WikiBuilder().text("!path ").child(0));
        addTranslation(Preformat.symbolType, new WikiBuilder().text("{{{").child(0).text("}}}"));
        addTranslation(Variable.symbolType, new WikiBuilder().text("${").child(0).text("}"));
    }

    private static void addTranslation(SymbolType symbolType, Translation translation) {
        translations.put(symbolType, translation);
    }

    public WikiTranslator(SourcePage page) {
        super(page);
    }

    @Override
    protected Translation getTranslation(SymbolType symbolType) {
        return translations.get(symbolType);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy