Mercurial > public > html2wiki
comparison src/org/nwoca/ssdt/tools/html2wiki/DeleteTransformer.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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f8b1ea49d065 |
---|---|
1 package org.nwoca.ssdt.tools.html2wiki; | |
2 | |
3 import java.util.regex.*; | |
4 | |
5 class DeleteTransformer implements Transformer { | |
6 private Pattern delete; | |
7 | |
8 public DeleteTransformer(String regex, boolean multiLine) { | |
9 delete = Pattern.compile(regex, multiLine ? Pattern.MULTILINE : 0); | |
10 } | |
11 | |
12 public DeleteTransformer(String regex) { | |
13 this(regex,false); | |
14 } | |
15 | |
16 public void apply(StringBuffer buffer) { | |
17 Matcher matcher = delete.matcher(buffer); | |
18 | |
19 boolean first = true; | |
20 while (matcher.find(first ? 0 : matcher.start() )) { | |
21 buffer.delete(matcher.start(),matcher.end()); | |
22 first = false; | |
23 } | |
24 | |
25 } | |
26 | |
27 public String toString() { | |
28 return "Delete: " + delete.pattern(); | |
29 } | |
30 } |