HTML5 parsing is relatively easy, because behavior for tag soup is 100% specified. That is, in theory, all conformant HTML5 parsers should output the same DOM for any arbitrary byte sequence.
Layout is much harder because the CSS spec is full of UB, so you will have to do some reverse engineering there.