Mercurial > public > html2wiki
view 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 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("(?m)^\\s","\r "); buffer.replace(matcher.start(),matcher.end(),temp); first = false; } } public String toString() { return "Preserving <pre> tag spacing"; } }