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

100% Statements 24/24
100% Branches 4/4
100% Functions 1/1
100% Lines 23/23

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 22 23 242x 2x 2x 2x 2x 2x 24528x 24528x 24528x 24528x 24528x 73772x 73772x 24528x 24528x 24528x 24528x 24528x 24528x 24528x 24528x 24528x 24528x  
/** @import { AST } from '#compiler' */
/** @import { Parser } from '../index.js' */
import { decode_character_references } from '../utils/html.js';
 
/** @param {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<AST.Text>>} */
	parser.append({
		type: 'Text',
		start,
		end: parser.index,
		raw: data,
		data: decode_character_references(data, false)
	});
}