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 java.util.regex.*;
07:
08: public class PreProcessorLiteralWidget extends WikiWidget {
09: public static final String REGEXP = "!-.*?-!";
10: public static final Pattern pattern = Pattern.compile("!-(.*?)-!",
11: Pattern.MULTILINE + Pattern.DOTALL);
12: private String literal = null;
13: private int literalNumber;
14:
15: public PreProcessorLiteralWidget(ParentWidget parent, String text) {
16: super (parent);
17: Matcher match = pattern.matcher(text);
18: if (match.find()) {
19: literal = match.group(1);
20: literalNumber = this .parent.defineLiteral(literal);
21: }
22: }
23:
24: public String render() throws Exception {
25: return "!lit(" + literalNumber + ")";
26: }
27:
28: public String asWikiText() throws Exception {
29: return "!-" + literal + "-!";
30: }
31: }
|