summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tikzit/src/common/GraphElementProperty.m10
-rw-r--r--tikzit/src/common/tikzlexer.lm6
-rw-r--r--tikzit/src/common/tikzparser.ym5
3 files changed, 14 insertions, 7 deletions
diff --git a/tikzit/src/common/GraphElementProperty.m b/tikzit/src/common/GraphElementProperty.m
index 9751230..4b47ca6 100644
--- a/tikzit/src/common/GraphElementProperty.m
+++ b/tikzit/src/common/GraphElementProperty.m
@@ -118,7 +118,15 @@
} else if ([self isKeyMatch]) {
return [NSString stringWithFormat:@"%@=*", [self key]];
} else {
- return [NSString stringWithFormat:@"%@=%@", [self key], [self value]];
+ static NSCharacterSet *avoid = nil;
+ if (avoid == nil)
+ avoid = [[NSCharacterSet characterSetWithCharactersInString:@",="] retain];
+
+ if ([[self value] rangeOfCharacterFromSet:avoid].length > 0) {
+ return [NSString stringWithFormat:@"%@={%@}", [self key], [self value]];
+ } else {
+ return [NSString stringWithFormat:@"%@=%@", [self key], [self value]];
+ }
}
}
diff --git a/tikzit/src/common/tikzlexer.lm b/tikzit/src/common/tikzlexer.lm
index c6deb3f..9418d83 100644
--- a/tikzit/src/common/tikzlexer.lm
+++ b/tikzit/src/common/tikzlexer.lm
@@ -77,19 +77,19 @@ at return AT;
}
\{ {
- NSMutableString *buf = [NSMutableString stringWithString:@"{"];
+ NSMutableString *buf = [NSMutableString string];
unsigned int brace_depth = 1;
while (1) {
char c = input();
// eof reached before closing brace
if (c == '\0' || c == EOF) yyterminate();
-
- [buf appendFormat:@"%c", c];
+
if (c == '{') brace_depth++;
else if (c == '}') {
brace_depth--;
if (brace_depth == 0) break;
}
+ [buf appendFormat:@"%c", c];
}
NSString *s = [buf copy];
diff --git a/tikzit/src/common/tikzparser.ym b/tikzit/src/common/tikzparser.ym
index d8de575..57f0600 100644
--- a/tikzit/src/common/tikzparser.ym
+++ b/tikzit/src/common/tikzparser.ym
@@ -103,7 +103,7 @@ property:
[p release];
};
-val: propsyms { $$ = $<nsstr>1; } | QUOTEDSTRING { $$ = $<nsstr>1; };
+val: propsyms { $$ = $<nsstr>1; } | QUOTEDSTRING { $$ = $<nsstr>1; } | DELIMITEDSTRING { $$ = $<nsstr>1; };
propsyms:
propsym { $$ = $<nsstr>1; }
| propsyms propsym
@@ -132,8 +132,7 @@ nodelabel:
DELIMITEDSTRING
{
Node *n = [[TikzGraphAssembler currentAssembler] currentNode];
- NSString *label = $<nsstr>1;
- [n setLabel:[label substringWithRange:NSMakeRange(1, [label length]-2)]];
+ [n setLabel:$<nsstr>1];
}
optanchor: | ANCHORCENTER;