02-16-2018, 01:17 AM | #346 |
Grand Sorcerer
Posts: 5,582
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
|
|
02-16-2018, 09:23 AM | #347 |
Sigil Developer
Posts: 7,627
Karma: 5433388
Join Date: Nov 2009
Device: many
|
|
Advert | |
|
02-16-2018, 10:08 AM | #348 |
Grand Sorcerer
Posts: 27,545
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Should be able to do it this evening or tomorrow morning at the latest.
|
02-16-2018, 10:57 AM | #349 |
Sigil Developer
Posts: 7,627
Karma: 5433388
Join Date: Nov 2009
Device: many
|
No rush! Thanks.
|
02-16-2018, 12:09 PM | #350 |
Sigil Developer
Posts: 7,627
Karma: 5433388
Join Date: Nov 2009
Device: many
|
BTW
I hopefully have fixed a segfault bug due to garbage collection in Python tk and added support for epub2, and preference being used for width of images which can be edited by the user but defaults to 500 pixels. It has Doitsu's linux nsvg2png and DiapDealer's nsvg2png32.exe and nsvg2png64.exe. I will update it with older nsvg2png binaries for Linux later ... but this should be at least testable now by others with recent Linux systems, Macs, and Windows. Any feedback welcome. Last edited by KevinH; 02-16-2018 at 08:49 PM. |
Advert | |
|
02-16-2018, 04:15 PM | #351 |
Grand Sorcerer
Posts: 27,545
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Here are the linux binaries built with gcc 4.8.4
Also ... you don't have to accommodate my nsvg2png32/64.exe naming in your plugin's python code. Feel free to rename them to the standard nsvg2png.exe in their respective folders if you like. I was just building them on the same machine in the same folder and needed to differentiate (and didn't take the time to zip them up in separate win32/win64 folders before uploading). Last edited by DiapDealer; 02-16-2018 at 07:34 PM. |
02-16-2018, 08:36 PM | #352 |
Sigil Developer
Posts: 7,627
Karma: 5433388
Join Date: Nov 2009
Device: many
|
Hi DiapDealer,
Thank You! BTW: I actually like with the name change on windows, as it makes sense to me. |
02-17-2018, 12:07 PM | #353 |
Grand Sorcerer
Posts: 27,545
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
RE the windows GIF file permissions error deleting the temp folder .... I'm attaching a version of the plugin that seems to work for me on Windows (Vista) and Linux. Kevin: diff the accessgui.py file against the 036 version you posted upthread to see the minor change I made.
|
02-17-2018, 12:18 PM | #354 |
Sigil Developer
Posts: 7,627
Karma: 5433388
Join Date: Nov 2009
Device: many
|
Wow great work! Thank you. I will test it on my Mac and then make an official posting of the plugin.
|
02-17-2018, 12:29 PM | #355 | |
Grand Sorcerer
Posts: 5,582
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
|
Quote:
|
|
02-17-2018, 12:44 PM | #356 |
Grand Sorcerer
Posts: 27,545
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
I honestly don't know why it works (or why only certain image-types experience the issue on Windows), but I'll take the win.
Pillow documentation clearly indicates that both file-paths and file-type objects are suitable for opening. There's no indication that one is any "better" than the other (nor have I seen any suggestions online anywhere that the file-type object will work better on Windows). *shrug* Perhaps the file-type object method leaves the closure to python rather than PIL? |
02-17-2018, 12:50 PM | #357 |
Sigil Developer
Posts: 7,627
Karma: 5433388
Join Date: Nov 2009
Device: many
|
Works like a charm on my Mac so we are good to go!
|
02-26-2018, 11:38 AM | #358 |
Sigil Developer
Posts: 7,627
Karma: 5433388
Join Date: Nov 2009
Device: many
|
Sample edit plugin to work with epubcfis
Hi Doitsu,
I have thrown together a static epubcfi conversion to line, col, and utf-8 file offset edit plugin. See the attached: cfitest_v010.zip It has two main support files: cficonvert.py and cfiparse.py The cfiparse.py is basically a modified version of Kovid's cfi parsing code, changed to work with Python 3 and to add some features to make my life easier. The cficonvert.py is the conversion routine that takes in a text epubcfi and book container object bk and returns the target filename, line number, column number and file offset into a utf-8 encoded version of the file. It uses the gumbo/bs4 parser to do the work. Since epubcfis are specific to an ebook and its contents, I have created a test epub to work with a specific set of test epubcfis. See the attached cfitest.epub It is based on the following idpf example (loosely): http://www.idpf.org/epub/linking/cfi/epub-cfi.html In order to exercise the plugin it needs a list of valid epubcfis to work from. When the plugin is launched with that ebook, it will ask you to navigate to select an epubcfi text file with the epubcfis to test one per line: Here is the attached cfis.txt to use for testing cfitest.epub with: Code:
epubcfi(/6/4[chap01ref]!/4[body01]/10[para05]/3:8) epubcfi(/6/4[chap01ref]!/4[body01]/16[svgimg]) epubcfi(/6/4[chap01ref]!/4[body01]/10[para05]/1:0) epubcfi(/6/4[chap01ref]!/4[body01]/10[para05]/2/1:0) epubcfi(/6/4[chap01ref]!/4[body01]/10[para05]/2/1:3) epubcfi(/6/4[chap01ref]!/4[body01]/20/5:5) Code:
epubcfi(/6/4[chap01ref]!/4[body01]/10[para05]/3:8) refers to the position right before the digit 8 in the paragraph with the ID para05. When producing CFIs for text locations, unless the text is defined by an img element's alt tag, one should always start with the reference to the (possibly-empty) chunk of XML character data that corresponds to the location and then trace the ancestor and reference chain to the Package Document root. The following examples show how EPUB CFIs can be constructed to reference additional content locations. Reference to the img element. epubcfi(/6/4[chap01ref]!/4[body01]/16[svgimg]) Reference to the location just before xxx. epubcfi(/6/4[chap01ref]!/4[body01]/10[para05]/1:0) Reference to the location just before yyy. epubcfi(/6/4[chap01ref]!/4[body01]/10[para05]/2/1:0) Reference to the location just after yyy. epubcfi(/6/4[chap01ref]!/4[body01]/10[para05]/2/1:3) Reference to the text node with "text here", tests text node step numbering without empty text nodes. epubcfi(/6/4[chap01ref]!/4[body01]/20/5:5) Code:
<?xml version="1.0"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>…</title> </head> <body id="body01"> <p>…</p> <p>…</p> <p>…</p> <p>…</p> <p id="para05">xxx<em>yyy</em>0123456789</p> <p>…</p> <p>…</p> <img id="svgimg" src="foo.svg" alt="…"/> <p>…</p> <p><span>hello</span><span>goodbye</span>text here<em>adieu</em>text there</p> </body> </html> FYI: This is very rough work thrown together quickly so there will most likely be problems that will have to be addressed! Please let me know what troubles you run into. Hope this helps. KevinH Last edited by KevinH; 02-26-2018 at 02:17 PM. |
02-26-2018, 12:42 PM | #359 |
Grand Sorcerer
Posts: 5,582
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
|
Hi KevinH,
This may be a stupid question. The epubcfis that you used all refer to chap01ref. For example: Code:
epubcfi(/6/4[chap01ref]!/4[body01]/10[para05]/3:8) If so, what part of the code do I need to change to select files with other spine ids? D. |
02-26-2018, 01:01 PM | #360 | |
Sigil Developer
Posts: 7,627
Karma: 5433388
Join Date: Nov 2009
Device: many
|
No the code is general, nothing hard coded. The chap01ref refers to the id that should be on that spine entry in the opf (I just forgot to add it to the content.opf of the cfitest.epub).
Typically you walk the content.opf node tree to get the file to parse next via a redirect on the spine. But the content opf has already been parsed in the plugin interface code so all we need is the element number of the spine. 2 for the first entry, 4 for the second entry, etc (don't ask about why they are numbered that way!). An assert id in the content opf should generally fail in this case since I did not add the id, but will not since the stepnum takes us to the correct spine item. This code should work for any epub as long as the epubcfis are correct for that epub. So to create an epubcfi for the first file in this epub, you simply change the /6/4 at the beginning of the epubcfi and remove the assert, to be /6 (the spine) and say /2 which would be the first spine element. Hope this helps, Kevi Quote:
Last edited by KevinH; 02-27-2018 at 11:08 AM. |
|
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Loading Plugin in development | Sladd | Development | 6 | 06-17-2014 06:57 PM |
Question for plugin development gurus | DiapDealer | Plugins | 2 | 02-04-2012 11:33 PM |
DR800 Plugin development for DR800/DR1000 | yuri_b | iRex Developer's Corner | 0 | 09-18-2010 09:46 AM |
Device plugin development | reader42 | Plugins | 10 | 03-29-2010 12:39 PM |
Calibre plugin development - Newbie problems | minstrel | Plugins | 5 | 04-12-2009 12:44 PM |