org.apache.maven.doxia.module.markdown.MarkdownUmlautEscaper Maven / Gradle / Ivy
/**
*
*/
package org.apache.maven.doxia.module.markdown;
import java.util.HashMap;
import java.util.Map;
/**
*
* @author Christian Bockermann <[email protected]>
*
*/
public class MarkdownUmlautEscaper implements MarkdownPreprocessor {
Map table = new HashMap();
public MarkdownUmlautEscaper() {
table.put(Character.valueOf('Ä'), "Ä");
table.put(Character.valueOf('ä'), "ä");
table.put(Character.valueOf('Ö'), "Ö");
table.put(Character.valueOf('ö'), "ö");
table.put(Character.valueOf('Ü'), "Ü");
table.put(Character.valueOf('ü'), "ü");
table.put(Character.valueOf('ß'), "ß");
System.out.println("table contains " + table.size()
+ " umlaut mappings.");
table.put('\u00DF', "ß");
System.out.println("table contains " + table.size()
+ " umlaut mappings.");
}
/**
* @see org.apache.maven.doxia.module.markdown.MarkdownPreprocessor#process(java.lang.String,
* java.util.Map)
*/
public String process(String source, Map subs) {
String str = source;
for (Character c : table.keySet()) {
while (str.indexOf(c) >= 0) {
String ch = c.toString();
String repl = table.get(c);
System.out
.println("Replacing '" + ch + "' with '" + repl + "'");
str = str.replace(c.toString(), table.get(c));
}
}
return str;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy