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