Skip to content
Browse files

Allow NuMarkupOperators to have nil tags.

  • Loading branch information...
1 parent 04b35f4 commit 51cc9edabbee23755293a3cbbe1a2d7ecfc05f1b @timburks committed
Showing with 28 additions and 27 deletions.
  1. +28 −27 objc/Nu.m
View
55 objc/Nu.m
@@ -11274,33 +11274,34 @@ - (id) initWithTag:(NSString *) _tag prefix:(NSString *) _prefix contents:(id) _
// Scan through the tag looking for "." or "#" characters.
// When we find them, we split the and use the following strings as class or id attributes.
- NSScanner *scanner = [NSScanner scannerWithString:_tag];
- NSCharacterSet *scanSet = [NSCharacterSet characterSetWithCharactersInString:@".#"];
- NSString *token;
- char typeFlag = 0;
- while ([scanner scanUpToCharactersFromSet:scanSet intoString:&token]) {
- if (typeFlag == 0) {
- _tag = token;
- } else if (typeFlag == '.') {
- if (!tagClasses) {
- tagClasses = [[NSMutableArray alloc] init];
- }
- [tagClasses addObject:token];
- } else if (typeFlag == '#') {
- if (!tagIds) {
- tagIds = [[NSMutableArray alloc] init];
- }
- [tagIds addObject:token];
- }
- if ([scanner scanCharactersFromSet:scanSet intoString:&token]) {
- if ([token length]) {
- typeFlag = [token characterAtIndex:[token length] - 1];
- } else {
- typeFlag = 0;
- }
- }
- }
-
+ if (_tag) {
+ NSScanner *scanner = [NSScanner scannerWithString:_tag];
+ NSCharacterSet *scanSet = [NSCharacterSet characterSetWithCharactersInString:@".#"];
+ NSString *token;
+ char typeFlag = 0;
+ while ([scanner scanUpToCharactersFromSet:scanSet intoString:&token]) {
+ if (typeFlag == 0) {
+ _tag = token;
+ } else if (typeFlag == '.') {
+ if (!tagClasses) {
+ tagClasses = [[NSMutableArray alloc] init];
+ }
+ [tagClasses addObject:token];
+ } else if (typeFlag == '#') {
+ if (!tagIds) {
+ tagIds = [[NSMutableArray alloc] init];
+ }
+ [tagIds addObject:token];
+ }
+ if ([scanner scanCharactersFromSet:scanSet intoString:&token]) {
+ if ([token length]) {
+ typeFlag = [token characterAtIndex:[token length] - 1];
+ } else {
+ typeFlag = 0;
+ }
+ }
+ }
+ }
tag = _tag ? [_tag stringByReplacingOccurrencesOfString:@"=" withString:@":"] : nil;
[tag retain];
prefix = _prefix ? _prefix : [elementPrefixes objectForKey:tag];

0 comments on commit 51cc9ed

Please sign in to comment.
Something went wrong with that request. Please try again.