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 java.util.regex.Matcher;
06: import java.util.regex.Pattern;
07:
08: // created by Jason Sypher
09:
10: public class StrikeWidget extends ParentWidget {
11: public static final String REGEXP = "--(?:[^-].+?)--";
12:
13: private static final Pattern pattern = Pattern.compile("--(.+?)--",
14: Pattern.MULTILINE + Pattern.DOTALL);
15:
16: // The following regexp is intersting becuase each addition char
17: // in the string to match would double the time it took to parse.
18: // public static final String REGEXP = "--(?:(?:[^-]+[-]?[^-]+)+)--";
19:
20: public StrikeWidget(ParentWidget parent, String text)
21: throws Exception {
22: super (parent);
23: Matcher match = pattern.matcher(text);
24: if (match.find())
25: addChildWidgets(match.group(1));
26: }
27:
28: public String render() throws Exception {
29: StringBuffer strike = new StringBuffer(
30: "<span class=\"strike\">");
31: strike.append(childHtml()).append("</span>");
32: return strike.toString();
33:
34: }
35:
36: }
|