Hi All,
This is just to provide a head's up. Recent work, that will probably make it into the next release, has made epub3 editing in Sigil much more of an equal partner (at least for simple epub3 ebooks that stick to epub2 main features but done in html5).
Users will be provided with a new "General Settings" Preference window where they can set what epub version that would like all new documents to start with.
That means Mend(), splitting Files, adding existing files, index generation, ncx generation, and basic xhtml editing are now epub version aware and should not break epub3 ebooks by using the wrong doctypes and things. Also a new "Epub 3 Tools" submenu under Tools will be provided with epub3 specific tools such as "Updating Manifest Properties", and "Nav Generator".
For plugin Developers, that means starting with the next release, if your plugin was only designed to work with one type of epub due to assumptions about DOCTYPES or use of named entities and the like (epub3 only allows numeric entities) - you will need to be able to get the epub version of the ebook your plugin has been passed easily.
So we have added a new interface:
bk.epub_version()
It will return a unicode string indicating the package version attribute of the ebook being worked on by your plugin - typically returning "2.0" or "3.0".
For example, the epub3-itizer is designed to work only with valid epub2 ebooks. So my next version of the plugin will check for the required epub version and error out with a message if passed in an epub3.
The snippet of code to do that is provided as follows:
Code:
epubversion = "2.0"
if bk.launcher_version() >= 20160102:
epubversion = bk.epub_version()
if epubversion.startswith("3"):
print("Error: ePub3-itizer requires a valid Epub 2.0 ebook as input")
return -1
So please look at your plugin code and see if it makes any assumptions or uses DOCTYPES and things that are epub 2 only. If so, consider either erroring out with a message similar to the code snippet above, or better yet ... us the bk.epub_version() call to properly set DOCTYPES, convert named entities to numeric entities, and things like that so that your plugin will work under both epub2 and epub3 ebooks without introducing any breakage.
Comments and questions welcome ...
KevinH
ps. If launcher_version < 20160102, it is safe to assume that you plugin has been passed an epub2 ebook for all intents and purposes.
pps. If people would like to see one approach to converted named entities to numeric entities, please check out the epub3-itizer code base which handles that.