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