![]() |
Calling Sigil menu functions in plugin?
Hi,
I've written a small, personal-use, plug-in to perform some find-and-replace, called mara01. That works fine, but the actual sequence of events when importing my book to Sigil is as follows: 1. Import docx + css via plugin (1) 2. Run plugin, shadycharacters (2) 3. Restructure epub to Sigil norm (tools) 4. Add cover, cover_01.jpg (tools) 5. Add metadata – title, author (tools, F8) 6. Run mara01 plugin (3) 7. Spit at markers (edit, F6) 8. Create TOC for h1 (tools, Ctrl-T) Step 6 is my plugin, but ideally I'd like to add as many of the other steps as I can. Any advice and/or suggestions as to how to go about this? P.S. not really a python-person |
You can't call Sigil Menu functions from a plugin. You could probably manage to call another plugin, but it would be a precarious, fragile thing at best.
|
So, I guess the follow-up is can anyone recommend any existing plugins I can cannibalise that do any of the following?
1. Add meta-data 2. Import covers |
Quote:
For the first task you'll need: bk.getmetadataxml() bk.setmetadataxml(new_metadata) For the second task you'll need: bk.addfile() bk.spine_insert_before() (if it's an HTML cover file) (You'll find some code examples in the test plugin.) |
Many thanks - and, yes, I read the guide! (believe it or not)
|
Quote:
|
Ah - no, I'd read a different, more basic, guide.
Nearly there! (got the metadata working, now just the cover) |
Okay, so below is my final code, which does what I want.
The Sigil well-formed check doesn't give any errors, but is there anything obviously wrong with it? (I know very little about how an epub should be structured) Code:
# -*- coding: utf-8 -*- |
Quote:
Shameless plug: I created a Sigil EPUBCheck plugin that you could use if you don't mind installing Java. |
Quote:
Thanks Doitsu. It's a winner. |
| All times are GMT -4. The time now is 08:41 PM. |
Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.