Read a run of template text, leaving the cursor where that text ended.
This is a lexer that answers the question where in the markup the next value
lands, because that decides whether it can be represented by a processing
instruction or has to be written out verbatim.
The parser can't answer this because it needs the finished text with every
interpolated value already written, but the way the values are written (i.e.
with or without whitespace) depends on the answer.
It is deliberately not a validator and rejects nothing, since the parser will
validate a moment later and will say it better. All it has to get right is which
of three places the text ended in, and how many elements are open there:
in element content, where a value can be stood in for by a processing
instruction, so long as an element encloses it
inside a tag, where no processing instruction can go, so the value is
written out instead
inside a processing instruction, a comment or a CDATA section, likewise
Read a run of template text, leaving the cursor where that text ended.
This is a lexer that answers the question where in the markup the next value lands, because that decides whether it can be represented by a processing instruction or has to be written out verbatim.
The parser can't answer this because it needs the finished text with every interpolated value already written, but the way the values are written (i.e. with or without whitespace) depends on the answer.
It is deliberately not a validator and rejects nothing, since the parser will validate a moment later and will say it better. All it has to get right is which of three places the text ended in, and how many elements are open there: