//
//  XTHtmlTagQ.m
//  TadsTerp
//
//  Created by Rune Berg on 07/04/14.
//  Copyright (c) 2014 Rune Berg. All rights reserved.
//

#import "XTHtmlTagQ.h"
#import "XTBaseTextHandler.h"


@implementation XTHtmlTagQ

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

+ (BOOL)standalone
{
	return NO;
}

//TODO !!! simplistic wrt. html tads (nesting, quote char, ws handling...)
- (void)format:(NSObject<XTOutputFormatterProtocol> *)formatter
   textHandler:(XTBaseTextHandler *)textHandler
{
	[super format:formatter textHandler:textHandler];
	
	NSArray *formattedElements = [formatter handleHtmlTagQ:self];
	[textHandler receiveFormattedElements:formattedElements];
}

//TODO !!! simplistic wrt. html tads (nesting, quote char, ws handling...)
- (void)formatExit:(NSObject<XTOutputFormatterProtocol> *)formatter
	   textHandler:(XTBaseTextHandler *)textHandler
{
	NSArray *formattedElements;
	if (! self.hasFormattedExit) {
		formattedElements = [formatter handleHtmlTagQ:self];
		[textHandler receiveFormattedElements:formattedElements];
	} else {
		formattedElements = [NSArray new];
	}
	
	[super formatExit:formatter textHandler:textHandler];
}

@end
