Mercurial > public > html2wiki
view src/org/nwoca/ssdt/tools/html2wiki/CloseTagTransformer.java @ 0:f8b1ea49d065
Initial version of crude HTML to WikiText converter. Customized for converting HTML files from DEC Document into Wiki markup.
author | smith@nwoca.org |
---|---|
date | Fri, 12 May 2006 16:45:42 -0400 |
parents | |
children |
line wrap: on
line source
/* * CloseTagTransformer.java * * Created on May 10, 2006, 10:42 AM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package org.nwoca.ssdt.tools.html2wiki; import java.util.regex.*; /** * * @author SMITH */ public class CloseTagTransformer implements Transformer { private Pattern startPattern; private Pattern terminationPattern; private String terminator; /** Creates a new instance of CloseTagTransformer */ public CloseTagTransformer(String startExp, String termExp, String terminator) { this.startPattern = Pattern.compile(startExp); this.terminationPattern = Pattern.compile(termExp); this.terminator = terminator; } public void apply(StringBuffer buffer) { Matcher startMatcher = startPattern.matcher(buffer); Matcher terminateMatcher = terminationPattern.matcher(buffer); boolean first = true; while (startMatcher.find()) { if(terminateMatcher.find(startMatcher.end())) { buffer.insert(terminateMatcher.start(),terminator); } } } public String toString() { return "Closing: " + startPattern.pattern() + " with " + terminator; } }