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