d1a4aeb5e1
The parser is initialized with a HTML string which can be parsed as a document or a document fragment. When parsing a fragment a context element should be provided. It is also possible to parse the same string as a fragment for different context elements. In this case the parser reset its internal state and runs the parsing algorithm again. Parsing a fragment for the same context element runs the algorithm only once, since the parser caches the context element and the parsing results.
30 lines
564 B
Objective-C
30 lines
564 B
Objective-C
//
|
|
// HTMLTokenizer.h
|
|
// HTMLKit
|
|
//
|
|
// Created by Iska on 19/09/14.
|
|
// Copyright (c) 2014 BrainCookie. All rights reserved.
|
|
//
|
|
|
|
#import <Foundation/Foundation.h>
|
|
#import "HTMLToken.h"
|
|
#import "HTMLTokenizerStates.h"
|
|
|
|
/**
|
|
* HTML Tokenizer
|
|
* https://html.spec.whatwg.org/multipage/syntax.html#tokenization
|
|
*/
|
|
|
|
@class HTMLParser;
|
|
|
|
@interface HTMLTokenizer : NSEnumerator
|
|
|
|
@property (nonatomic, assign) HTMLTokenizerState state;
|
|
@property (nonatomic, weak, readonly) HTMLParser *parser;
|
|
|
|
- (instancetype)initWithString:(NSString *)string;
|
|
|
|
- (void)reset;
|
|
|
|
@end
|