Permalink
Browse files

The parser now merges consecutive labels.

When labels such as foo: and bar: appear consecutively,
they are combined into a single label foo:bar:.

This is helpful when generating markup from the automatic &-operators;
now attributes can contain ':' characters.
  • Loading branch information...
1 parent 7c80027 commit 42c345a20f7deaac2a4a6e7ffdf731f0d330e3af @timburks timburks committed Jul 6, 2013
Showing with 17 additions and 1 deletion.
  1. +11 −0 objc/Nu.m
  2. +6 −1 test/test_markup.nu
View
@@ -9420,6 +9420,17 @@ - (void) addAtomCell:(id)atom
{
ParserDebug(@"addAtomCell: depth = %d atom = %@", depth, [atom stringValue]);
+ // when we have two consecutive labels, concatenate them.
+ // this allows us to have ':' characters inside labels.
+ if ([atom isKindOfClass:[NuSymbol class]] && [atom isLabel]) {
+ id currentCar = [current car];
+ if ([currentCar isKindOfClass:[NuSymbol class]] && [currentCar isLabel]) {
+ NuSymbol *combinedLabel = [symbolTable symbolWithString:[[currentCar stringValue] stringByAppendingString:[atom stringValue]]];
+ [current setCar:combinedLabel];
+ return;
+ }
+ }
+
NuCell *newCell;
if (comments) {
NuCellWithComments *newCellWithComments = [[[NuCellWithComments alloc] init] autorelease];
View
@@ -69,4 +69,9 @@
(assert_equal golden markup)
(set markup (&div#myid.myclass))
(set golden "<div id=\"myid\" class=\"myclass\"></div>")
- (assert_equal golden markup)))
+ (assert_equal golden markup))
+
+ (- testEmbeddedColons is
+ (set markup (&div ns:foo:123 x:bar:456))
+ (set golden "<div ns:foo=\"123\" x:bar=\"456\"></div>")
+ (assert_equal golden markup)))

0 comments on commit 42c345a

Please sign in to comment.