All files / src/compiler/phases/1-parse/state text.js

100% Statements 22/22
100% Branches 4/4
100% Functions 1/1
100% Lines 21/21

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 222x 2x 2x 2x 21405x 21405x 21405x 21405x 21405x 64178x 64178x 21405x 21405x 21405x 21405x 21405x 21405x 21405x 21405x 21405x 21405x  
import { decode_character_references } from '../utils/html.js';
 
/** @param {import('../index.js').Parser} parser */
export default function text(parser) {
	const start = parser.index;
 
	let data = '';
 
	while (parser.index < parser.template.length && !parser.match('<') && !parser.match('{')) {
		data += parser.template[parser.index++];
	}
 
	/** @type {ReturnType<typeof parser.append<import('#compiler').Text>>} */
	parser.append({
		type: 'Text',
		start,
		end: parser.index,
		raw: data,
		data: decode_character_references(data, false)
	});
}