Mercurial > public > html2wiki
view src/org/nwoca/ssdt/tools/html2wiki/ChapterTransformer.java @ 4:22ed6d93442c
Start modifying transformers to Confluence wiki syntax
author | smith@nwoca.org |
---|---|
date | Tue, 25 Jan 2011 21:59:31 -0500 |
parents | f8b1ea49d065 |
children |
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{panel}{toc}{panel}"); first = false; } } public String toString() { return "Replace Chapter markers"; } }