View Single Post
Old Today, 10:32 AM   #40
BeckyEbook
Wizard
BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.
 
BeckyEbook's Avatar
 
Posts: 1,104
Karma: 4000789
Join Date: Jan 2017
Location: Poland
Device: Various
@KevinH, right, I'd prefer a plain text insertion over gumbo, simply because it's the smallest possible change: a Checkpoint Compare would show just the added line(s) and nothing else.

I don't think the comments make it complicated though. The XML prolog allows comments both before and after the doctypedecl, so nothing needs to be found or reordered:
  • xml header missing -> prepend it (it must be first anyway, so nothing can precede it)
  • DOCTYPE missing -> insert it right after the xml header; any comments simply end up after the DOCTYPE, which is still valid

The QXmlStreamReader pass in WellFormedErrorForSource already tells us which of the two is missing, so the only regex needed is one anchored at the start for the xml header. And it's a pure QString function, so it parallelizes just as well.

If you think this approach is worth a try, I could give it a go this evening and put together a patch for you to look at. I can't promise it'll be ready today though, as each Sigil build takes about 10 minutes on my machine, and I'd like to test it properly with both epub2 and epub3 first. But if you'd rather go with gumbo, that's absolutely fine with me too: the important part for me is just no warning :)
BeckyEbook is offline   Reply With Quote