CHM: be more lenient when parsing broken ToCs
PDF: fix logic typo
undo unintended code reverts in r8321