diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/nwoca/ssdt/tools/html2wiki/PreTagTransformer.java	Fri May 12 16:45:42 2006 -0400
@@ -0,0 +1,28 @@
+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("(?m)^\\s","\r&nbsp;");
+            buffer.replace(matcher.start(),matcher.end(),temp);
+            first = false;
+        }
+     
+    }
+        
+    public String toString() {
+        return "Preserving <pre> tag spacing";
+    }
+
+}
\ No newline at end of file