Reads tokens from text and returns them by invoking a callback.
Tokens are guaranteed to be returned in correct order. Missing tokens are inserted to restore the correct order if needed.
Tokenizer options.
import { createTokenizer, htmlTokenizerOptions } from 'tag-soup';const tokenizer = createTokenizer(htmlTokenizerOptions);tokenizer.tokenize( 'Hello, <b>Bob</b>!', (token, startIndex, endIndex) => { // Handle token here },); Copy
import { createTokenizer, htmlTokenizerOptions } from 'tag-soup';const tokenizer = createTokenizer(htmlTokenizerOptions);tokenizer.tokenize( 'Hello, <b>Bob</b>!', (token, startIndex, endIndex) => { // Handle token here },);
Reads tokens from text and returns them by invoking a callback.
Tokens are guaranteed to be returned in correct order. Missing tokens are inserted to restore the correct order if needed.