[jboss-cvs] jboss-seam ...
Christian Bauer
christian at hibernate.org
Wed Dec 19 00:15:34 EST 2007
User: cbauer
Date: 07/12/19 00:15:34
Modified: jboss-seam seam-text.g
Log:
Added Macro class and extended macro syntax with key/value pairs
Revision Changes Path
1.42 +45 -6 jboss-seam/seam-text.g
(In the diff below, changes in quantity of whitespace are not shown.)
Index: seam-text.g
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/seam-text.g,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -b -r1.41 -r1.42
--- seam-text.g 12 Nov 2007 07:29:41 -0000 1.41
+++ seam-text.g 19 Dec 2007 05:15:34 -0000 1.42
@@ -10,9 +10,20 @@
defaultErrorHandler=false;
}
{
- private java.util.Set htmlElements = new java.util.HashSet( java.util.Arrays.asList( new String[] { "a", "p", "q", "blockquote", "code", "pre", "table", "tr", "td", "th", "ul", "ol", "li", "b", "i", "u", "tt", "del", "em", "hr", "br", "div", "span", "h1", "h2", "h3", "h4", "img"} ) );
+ private java.util.Set htmlElements = new java.util.HashSet( java.util.Arrays.asList( new String[] { "a", "p", "q", "blockquote", "code", "pre", "table", "tr", "td", "th", "ul", "ol", "li", "b", "i", "u", "tt", "del", "em", "hr", "br", "div", "span", "h1", "h2", "h3", "h4", "img" , "object", "param", "embed"} ) );
private java.util.Set htmlAttributes = new java.util.HashSet( java.util.Arrays.asList( new String[] { "src", "href", "lang", "class", "id", "style", "width", "height", "name", "value", "type", "wmode" } ) );
+ public class SeamTextMacro {
+ public String name;
+ public java.util.SortedMap<String,String> params = new java.util.TreeMap<String,String>();
+
+ public SeamTextMacro(String name) {
+ this.name = name;
+ }
+ }
+
+ private SeamTextMacro currentMacro;
+
private StringBuilder mainBuilder = new StringBuilder();
private StringBuilder builder = mainBuilder;
@@ -58,6 +69,10 @@
return "";
}
+ protected String macroInclude(SeamTextMacro m) {
+ return macroInclude(m.name);
+ }
+
protected String paragraphOpenTag() {
return "<p class=\"seamTextPara\">\n";
}
@@ -171,7 +186,7 @@
link: OPEN
{ beginCapture(); }
- (plain)*
+ (word|punctuation|escape|space)*
{ String text=endCapture(); }
EQ GT
{ beginCapture(); }
@@ -180,12 +195,36 @@
CLOSE
;
+/*
+
+[<=macro<param1=value "1"><param2=value '2'>]
+
+*/
macro: OPEN
LT EQ
- { beginCapture(); }
- attributeValue
- { String macroName = endCapture(); append(macroInclude(macroName)); }
+ mn:ALPHANUMERICWORD { currentMacro = new SeamTextMacro(mn.getText()); }
+ (macroParam)*
CLOSE
+ { append( macroInclude(currentMacro) ); currentMacro = null; }
+ ;
+
+macroParam:
+ LT
+ pn:ALPHANUMERICWORD
+ EQ
+ { beginCapture(); }
+ macroParamValue
+ { String pv = endCapture(); currentMacro.params.put(pn.getText(),pv); }
+ GT
+ ;
+
+macroParamValue:
+ ( amp:AMPERSAND { append(amp.getText()); } |
+ dq:DOUBLEQUOTE { append(dq.getText()); } |
+ sq:SINGLEQUOTE { append(sq.getText()); } |
+ an:ALPHANUMERICWORD { append(an.getText()); } |
+ p:PUNCTUATION { append(p.getText()); } |
+ space | specialChars )*
;
bold: STAR { append("<b>"); }
More information about the jboss-cvs-commits
mailing list