//
//  XTHtmlTagA.m
//  XTads
//
//  Created by Rune Berg on 17/10/15.
//  Copyright © 2015 Rune Berg. All rights reserved.
//

#import "XTHtmlTagA.h"
#import "XTStringUtils.h"
#import "XTOutputFormatterProtocol.h"


//TODO !!! instances don't look right in debugger -- because we test the *closing* instance, which has no attr

@implementation XTHtmlTagA

/*TODO rm
static NSArray *internetLinkPrefixes;

+ (void)initialize
{
	internetLinkPrefixes = @[@"http:", @"https:", @"ftp:", @"news:", @"mailto:", @"telnet:"];
}*/

+ (NSString *)name
{
	return @"a";
}

+ (NSArray *)allowedAttributes
{
	return @[];
}

+ (BOOL)standalone
{
	return NO;
}

- (NSArray *)dispatchToFormatter:(NSObject<XTOutputFormatterProtocol> *)formatter
{
	return [formatter handleHtmlTagA:self];
}

/*TODO rm
-(BOOL)isInternetLink
{
	// See http://www.tads.org/t3doc/doc/htmltads/deviate.htm#Achanges
	
	BOOL res = NO;
	NSString *href = [self attributeAsString:@"href"];
	if (href != nil) {
		href = [XTStringUtils trimLeadingAndTrailingWhitespace:href];
		href = [href lowercaseString];
		for (NSString* prefix in internetLinkPrefixes) {
			if ([href hasPrefix:prefix]) {
				res = YES;
				break;
			}
		}
	}
	return res;
}*/

@end
