01: // Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
02: // Released under the terms of the GNU General Public License version 2 or later.
03: package fitnesse.wikitext.widgets;
04:
05: import fitnesse.wikitext.WikiWidget;
06:
07: import java.util.regex.Matcher;
08: import java.util.regex.Pattern;
09:
10: public class HruleWidget extends WikiWidget {
11: public static final String REGEXP = "-{4,}";
12:
13: private static final Pattern pattern = Pattern.compile("-{4}(-*)");
14:
15: private int size = 0;
16:
17: public HruleWidget(ParentWidget parent, String text) {
18: super (parent);
19: Matcher match = pattern.matcher(text);
20: if (match.find())
21: size = match.group(1).length();
22: }
23:
24: public int size() {
25: return size;
26: }
27:
28: public String render() throws Exception {
29: StringBuffer html = new StringBuffer("<hr");
30: if (size > 0)
31: html.append(" size=\"").append(size + 1).append("\"");
32: html.append("/>");
33:
34: return html.toString();
35: }
36: }
|