Fix behavior when skipping SGML

For details, see the new test.