Mercurial > public > html2wiki
diff src/org/nwoca/ssdt/tools/html2wiki/ChapterTransformer.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 | 22ed6d93442c |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/org/nwoca/ssdt/tools/html2wiki/ChapterTransformer.java Fri May 12 16:45:42 2006 -0400 @@ -0,0 +1,32 @@ +package org.nwoca.ssdt.tools.html2wiki; + +import java.util.regex.*; + +class ChapterTransformer implements Transformer { + private Pattern chapterPattern = Pattern.compile("^<hr size=5>.*?<h1>(.*?)</h1>",Pattern.MULTILINE + Pattern.DOTALL); + private String category; + public ChapterTransformer() { + + } + public ChapterTransformer(String category) { + this.category = category; + } + + public void apply(StringBuffer buffer) { + Matcher matcher = chapterPattern.matcher(buffer); + + boolean first = true; + while (matcher.find( 0 )) { + buffer.replace(matcher.start(),matcher.end(), + "<chapter>" + matcher.group(1) +"</chapter>\n__TOC__" + + (category == null ? "" : "\n[[Category:" + category + "]]")); + first = false; + } + + } + + public String toString() { + return "Replace Chapter markers"; + } + +} \ No newline at end of file