changeset 769:c5f5b655f1f7

allow spaces in theme tags
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 10 Aug 2016 23:37:23 -0600
parents ef0fc9ad30c1
children 50f279d3f889
files core/src/luan/modules/parsers/Theme.java
diffstat 1 files changed, 25 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
diff -r ef0fc9ad30c1 -r c5f5b655f1f7 core/src/luan/modules/parsers/Theme.java
--- a/core/src/luan/modules/parsers/Theme.java	Sun Aug 07 21:03:14 2016 -0600
+++ b/core/src/luan/modules/parsers/Theme.java	Wed Aug 10 23:37:23 2016 -0600
@@ -52,11 +52,15 @@
 
 	private String parseDef() throws ParseException {
 		int start = parser.begin();
-		if( !parser.match("{define:") )
+		if( !parser.match('{') )
+			return parser.failure(null);
+		spaces();
+		if( !parser.match("define:") )
 			return parser.failure(null);
 		String name = parseName();
 		if( name==null )
 			throw exception("invalid block name");
+		spaces();
 		if( !parser.match('}') )
 			throw exception("unclosed define tag");
 		String block = parseBody("define:"+name);
@@ -102,11 +106,15 @@
 
 	private boolean matchEndTag(String tagName) {
 		parser.begin();
-/*
-		if( tagName.startsWith("define:") )
-			EndOfLine();
-*/
-		return parser.match("{/") && parser.match(tagName) && parser.match('}') ? parser.success() : parser.failure();
+		if( !parser.match('{') )
+			return parser.failure();
+		spaces();
+		if( !(parser.match('/') && parser.match(tagName)) )
+			return parser.failure();
+		spaces();
+		if( !parser.match('}') )
+			return parser.failure();
+		return parser.success();
 	}
 
 	private void addText(int start,int end,StringBuilder stmts) {
@@ -117,13 +125,17 @@
 
 	private String parseBlock() throws ParseException {
 		int start = parser.begin();
-		if( !parser.match("{block:") )
+		if( !parser.match('{') )
+			return parser.failure(null);
+		spaces();
+		if( !parser.match("block:") )
 			return parser.failure(null);
 		String name = parseName();
 		if( name==null ) {
 			parser.failure();
 			throw exception("invalid block name");
 		}
+		spaces();
 		if( !parser.match('}') )
 			return parser.failure(null);
 		String block = parseBody("block:"+name);
@@ -136,9 +148,11 @@
 		int start = parser.begin();
 		if( !parser.match('{') )
 			return parser.failure(null);
+		spaces();
 		String name = parseName();
 		if( name==null )
 			return parser.failure(null);
+		spaces();
 		if( !parser.match('}') )
 			return parser.failure(null);
 //		rtn = "<% env." + name + (attrs.isEmpty() ? "()" : table(attrs)) + " %>";
@@ -181,4 +195,8 @@
 		return FirstNameChar() || parser.inCharRange('0', '9');
 	}
 
+	private void spaces() {
+		while( parser.anyOf(" \t") );
+	}
+
 }