Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Sigil > Plugins

Notices

Reply
 
Thread Tools Search this Thread
Old 02-16-2018, 02:17 AM   #346
Doitsu
Wizard
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 4,307
Karma: 14277313
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by DiapDealer View Post
What version of gcc/libc was used? An older version would be best to ensure the widest range of compliance with different libc versions.
Unfortunately, I used the latest version, gcc 7.3. It might be better if you compiled the files with an older compiler.
Doitsu is offline   Reply With Quote
Old 02-16-2018, 10:23 AM   #347
KevinH
Wizard
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 3,101
Karma: 1931746
Join Date: Nov 2009
Device: many
@DiapDealer
If and when you get a free moment, that would be very helpful.

Thanks

Quote:
Originally Posted by Doitsu View Post
Unfortunately, I used the latest version, gcc 7.3. It might be better if you compiled the files with an older compiler.
KevinH is offline   Reply With Quote
Advert
Old 02-16-2018, 11:08 AM   #348
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 19,179
Karma: 99356142
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Should be able to do it this evening or tomorrow morning at the latest.
DiapDealer is online now   Reply With Quote
Old 02-16-2018, 11:57 AM   #349
KevinH
Wizard
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 3,101
Karma: 1931746
Join Date: Nov 2009
Device: many
No rush! Thanks.
KevinH is offline   Reply With Quote
Old 02-16-2018, 01:09 PM   #350
KevinH
Wizard
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 3,101
Karma: 1931746
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.
Attached Files
File Type: zip Access-Aide_v036.zip (236.9 KB, 26 views)

Last edited by KevinH; 02-16-2018 at 09:49 PM.
KevinH is offline   Reply With Quote
Advert
Old 02-16-2018, 05:15 PM   #351
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 19,179
Karma: 99356142
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).
Attached Files
File Type: zip nsvg2png_linux.zip (63.8 KB, 25 views)

Last edited by DiapDealer; 02-16-2018 at 08:34 PM.
DiapDealer is online now   Reply With Quote
Old 02-16-2018, 09:36 PM   #352
KevinH
Wizard
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 3,101
Karma: 1931746
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.
KevinH is offline   Reply With Quote
Old 02-17-2018, 01:07 PM   #353
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 19,179
Karma: 99356142
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.
Attached Files
File Type: zip Access-Aide_v036b1.zip (236.5 KB, 26 views)
DiapDealer is online now   Reply With Quote
Old 02-17-2018, 01:18 PM   #354
KevinH
Wizard
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 3,101
Karma: 1931746
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.
KevinH is offline   Reply With Quote
Old 02-17-2018, 01:29 PM   #355
Doitsu
Wizard
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 4,307
Karma: 14277313
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by DiapDealer View Post
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.
I've just tested this version on my Windows 10 machine and it works fine.
Doitsu is offline   Reply With Quote
Old 02-17-2018, 01:44 PM   #356
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 19,179
Karma: 99356142
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?
DiapDealer is online now   Reply With Quote
Old 02-17-2018, 01:50 PM   #357
KevinH
Wizard
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 3,101
Karma: 1931746
Join Date: Nov 2009
Device: many
Works like a charm on my Mac so we are good to go!
KevinH is offline   Reply With Quote
Old 02-26-2018, 12:38 PM   #358
KevinH
Wizard
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 3,101
Karma: 1931746
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)
And here the attached cfis_answers.txt you can use to check the results of the cfi conversion when it is run:
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)
And here is what chapter01.xhtml looks like inside the test epub:
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>
So please give that a try and see if you can use it to adapt your ACE Checker which outputs cfis to work with Sigil validation plugins.

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
Attached Files
File Type: zip cfitest_v010.zip (7.3 KB, 25 views)
File Type: txt cfis.txt (298 Bytes, 102 views)
File Type: txt cfis_answers.txt (1.0 KB, 106 views)
File Type: epub cfitest.epub (2.8 KB, 26 views)

Last edited by KevinH; 02-26-2018 at 03:17 PM.
KevinH is offline   Reply With Quote
Old 02-26-2018, 01:42 PM   #359
Doitsu
Wizard
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 4,307
Karma: 14277313
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)
However, the sample epub doesn't contain this id. Am I right in assuming that you hard-coded your example to only look in chapter01.xhtml?

If so, what part of the code do I need to change to select files with other spine ids?

D.
Doitsu is offline   Reply With Quote
Old 02-26-2018, 02:01 PM   #360
KevinH
Wizard
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 3,101
Karma: 1931746
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:
Originally Posted by Doitsu View Post
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)
However, the sample epub doesn't contain this id. Am I right in assuming that you hard-coded your example to only look in chapter01.xhtml?

If so, what part of the code do I need to change to select files with other spine ids?

D.

Last edited by KevinH; 02-27-2018 at 12:08 PM.
KevinH is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Loading Plugin in development Sladd Development 6 06-17-2014 07:57 PM
Question for plugin development gurus DiapDealer Plugins 2 02-05-2012 12:33 AM
DR800 Plugin development for DR800/DR1000 yuri_b iRex Developer's Corner 0 09-18-2010 10:46 AM
Device plugin development reader42 Plugins 10 03-29-2010 01:39 PM
Calibre plugin development - Newbie problems minstrel Plugins 5 04-12-2009 01:44 PM


All times are GMT -4. The time now is 07:51 PM.


MobileRead.com is a privately owned, operated and funded community.