Mercurial > public > html2wiki
comparison 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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f8b1ea49d065 |
---|---|
1 package org.nwoca.ssdt.tools.html2wiki; | |
2 | |
3 import java.util.regex.*; | |
4 | |
5 class ChapterTransformer implements Transformer { | |
6 private Pattern chapterPattern = Pattern.compile("^<hr size=5>.*?<h1>(.*?)</h1>",Pattern.MULTILINE + Pattern.DOTALL); | |
7 private String category; | |
8 public ChapterTransformer() { | |
9 | |
10 } | |
11 public ChapterTransformer(String category) { | |
12 this.category = category; | |
13 } | |
14 | |
15 public void apply(StringBuffer buffer) { | |
16 Matcher matcher = chapterPattern.matcher(buffer); | |
17 | |
18 boolean first = true; | |
19 while (matcher.find( 0 )) { | |
20 buffer.replace(matcher.start(),matcher.end(), | |
21 "<chapter>" + matcher.group(1) +"</chapter>\n__TOC__" + | |
22 (category == null ? "" : "\n[[Category:" + category + "]]")); | |
23 first = false; | |
24 } | |
25 | |
26 } | |
27 | |
28 public String toString() { | |
29 return "Replace Chapter markers"; | |
30 } | |
31 | |
32 } |