markup.ml
markup.ml copied to clipboard
Improve error messages for misnested elements
From https://github.com/ocsigen/tyxml/issues/322:
There is a popular way to style checkbox based on this HTML code:
<label class="switch" for="checkbox"> <input type="checkbox" id="checkbox" /> <div class="slider"></div> </label>What I did not realise is that this HTML, although popular, does not respect the specification (
divshould bespanhere).TyXML does detect that and correctly rejects the program:
let%html checkbox = "<label class='switch' for='checkbox'>" "<input type='checkbox' id='checkbox' />" "<div class='slider'></div>" "</label>"However, the error message is just wrong:
Error: Unmatched start tag 'label', pointing at the beginning of thelabelelement. It took me quite a long time to understand what was happening: it would be nice to have it pointing to thedivelement instead and state that it can't be within alabelelement.I'm using TyXML 4.6.0 with
tyxml-ppx.
cc @MBodin