24 lines
580 B
JavaScript
24 lines
580 B
JavaScript
/** @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;
|
|
|
|
while (parser.index < parser.template.length && !parser.match('<') && !parser.match('{')) {
|
|
parser.index++;
|
|
}
|
|
|
|
const data = parser.template.slice(start, parser.index);
|
|
|
|
/** @type {AST.Text} */
|
|
parser.append({
|
|
type: 'Text',
|
|
start,
|
|
end: parser.index,
|
|
raw: data,
|
|
data: decode_character_references(data, false)
|
|
});
|
|
}
|