comparison src/org/nwoca/ssdt/tools/html2wiki/PreTagTransformer.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 a634b4d554d4
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 PreTagTransformer implements Transformer {
6 private Pattern pattern = Pattern.compile("<pre>.*?</pre>",Pattern.MULTILINE + Pattern.DOTALL);
7 public PreTagTransformer() {
8
9 }
10
11 public void apply(StringBuffer buffer) {
12 Matcher matcher = pattern.matcher(buffer);
13
14 boolean first = true;
15 while (matcher.find( first ? 0 : matcher.end())) {
16 String temp = buffer.substring(matcher.start(),matcher.end());
17 temp = temp.replaceAll("(?m)^\\s","\r&nbsp;");
18 buffer.replace(matcher.start(),matcher.end(),temp);
19 first = false;
20 }
21
22 }
23
24 public String toString() {
25 return "Preserving <pre> tag spacing";
26 }
27
28 }