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: import fitnesse.html.HtmlUtil;
07: import java.util.regex.*;
08:
09: public class AnchorDeclarationWidget extends WikiWidget {
10:
11: public static final String REGEXP = "!anchor \\w+";
12:
13: private static final Pattern pattern = Pattern
14: .compile("!anchor (\\w*)");
15:
16: private String text, anchorName;
17:
18: public AnchorDeclarationWidget(ParentWidget parent, String text) {
19: super (parent);
20: this .text = text;
21: Matcher match = pattern.matcher(this .text);
22: if (match.find())
23: anchorName = match.group(1);
24: }
25:
26: public String render() throws Exception {
27: return HtmlUtil.makeAnchorTag(anchorName).html();
28: }
29: }
|