Theoretically, yes.
However, I recognize this code because it reminds me of your code from the TOCSaver plugin.
There, too, there is a problem (only in epub2) that epubcheck considers the hidden attribute invalid.
Code:
Col: 53: ERROR(RSC-005): Error while parsing file: attribute "hidden" not allowed here; expected attribute "class", "dir", "lang", "title" or "xml:lang"
So I would suggest something along these lines:
Code:
QString version = sink_resource->GetEpubVersion();
if (version.startsWith("3")) {
new_bodies.append(" <p id=\"" + section_id + "\" style=\"display:none\" hidden=\"hidden\"></p>\n" + updated_bodies[bookpath]);
} else {
new_bodies.append(" <p id=\"" + section_id + "\" style=\"display:none\"></p>\n" + updated_bodies[bookpath]);
}
I built Sigil just now and it passes epubcheck for epub2 and epub3.
I know your approach to epub2, however, in Poland at least 80-90% of new titles in bookstores are still epub2. The volume of epub3 files is gradually increasing, but this is happening extremely slowly.
P.S. In the modified TOCSaver plugin I use a similar condition (in three places in the code) and it works very well.