Parsing HTML can be done with a state machine. That’s how HTML5 defines how to parse it: https://html.spec.whatwg.org/multipage/syntax.html#syntax