view src/org/nwoca/ssdt/tools/html2wiki/PreTagTransformer.java @ 17:a88e2f8fb117 tip

added a replace transformer to remove ;) smilies
author ferrall@nwoca.org
date Tue, 08 Feb 2011 09:27:40 -0500
parents a634b4d554d4
children
line wrap: on
line source
package org.nwoca.ssdt.tools.html2wiki;

import java.util.regex.*;

class PreTagTransformer implements Transformer {
    private Pattern pattern = Pattern.compile("<pre>.*?</pre>",Pattern.MULTILINE + Pattern.DOTALL);
    public PreTagTransformer() {
         
    }
    
    public void apply(StringBuffer buffer) {
        Matcher matcher = pattern.matcher(buffer);
        
        boolean first = true;
        while (matcher.find( first ? 0 : matcher.end())) {
            String temp = buffer.substring(matcher.start(),matcher.end());
            temp = temp.replaceAll("\\\\\\[","[");
            temp = temp.replaceAll("\\\\\\]","]");
            buffer.replace(matcher.start(),matcher.end(),temp);
            first = false;
        }
     
    }
        
    public String toString() {
        return "Unescaping Pre tag contents";
    }

}