Mercurial > public > html2wiki
view 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 source
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"; } }