Fix <form> handling in table and body
We discovered some divergence from spec in <form> tag handling and a typo in reset_mode, while investigating an edge case where the parser enters an infinite loop (https://github.com/ahrefs/markup.ml/commit/8cca065dd4ca919eb5cbb65069f85fa54e123082). This PR fixes the divergence.
https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-intable
A start tag whose tag name is "form"
Parse error. If there is a template element on the stack of open elements, or if the form element pointer is not null, ignore the token.
Otherwise: Insert an HTML element for the token, and set the form element pointer to point to the element created. Pop that form element off the stack of open elements.
https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inbody
An end tag whose tag name is "form"
If there is no template element on the stack of open elements, then run these substeps:
Let node be the element that the form element pointer is set to, or null if it is not set to an element. Set the form element pointer to null. If node is null or if the stack of open elements does not have node in scope, then this is a parse error; return and ignore the token. Generate implied end tags. If the current node is not node, then this is a parse error. Remove node from the stack of open elements.
If there is a template element on the stack of open elements, then run these substeps instead: If the stack of open elements does not have a form element in scope, then this is a parse error; return and ignore the token. Generate implied end tags. If the current node is not a form element, then this is a parse error. Pop elements from the stack of open elements until a form element has been popped from the stack.