MobileRead Forums

MobileRead Forums (https://www.mobileread.com/forums/index.php)
-   Plugins (https://www.mobileread.com/forums/forumdisplay.php?f=268)
-   -   [Plugin] KePub Output (https://www.mobileread.com/forums/showthread.php?t=281793)

djazz 12-16-2016 10:35 AM

[Plugin] KePub Output
 
1 Attachment(s)
This output plugin adds kobo spans in all xhtml files, to every sentence. This is to make to the Kobo reader remember how far you've read into a chapter and it also enables annotating and bookmarking.

When you've ran the plugin, it asks where you want to save it. Save as .kepub.epub!

It's based code from the Calibre KePub Output Plugin, all credit goes to jgoguen.
I modified it to work in Python 3 since that is what Sigil uses.

I have only tried it with one story (EPUB3) on Linux, so it might not work for all!

Example
Spoiler:
Input
Code:

<p>But why? Nobody really knew what was outside, if there was anything out there at all. Historical books suggested the world outside was blasted, lifeless and poisonous. That was, at least, the common and logical assumption. But a ghost story somepony told at my first (and only) slumber party had given me horrible nightmares and still lurked in the shadows of my head: a tale of a pony who somehow got the Stable door open and stepped outside… only to find out that there <i>was</i> no outside! Just a great nothingness that whisked the pony away, devouring her soul so that she was nothingness too.</p>
Output
Code:

<p><span class="koboSpan" id="kobo.52.1">But why? </span><span class="koboSpan" id="kobo.52.2">Nobody really knew what was outside, if there was anything out there at all. </span><span class="koboSpan" id="kobo.52.3">Historical books suggested the world outside was blasted, lifeless and poisonous. </span><span class="koboSpan" id="kobo.52.4">That was, at least, the common and logical assumption. </span><span class="koboSpan" id="kobo.52.5">But a ghost story somepony told at my first (and only) slumber party had given me horrible nightmares and still lurked in the shadows of my head: </span><span class="koboSpan" id="kobo.52.6">a tale of a pony who somehow got the Stable door open and stepped outside… only to find out that there </span><i><span class="koboSpan" id="kobo.52.7">was</span></i><span class="koboSpan" id="kobo.53.1"> no outside! </span><span class="koboSpan" id="kobo.53.2">Just a great nothingness that whisked the pony away, devouring her soul so that she was nothingness too.</span></p>
(Snippet from first chapter of Fallout: Equestria)


You can also check out my helper tool epubmake, which is a Makefile and includes epubcheck, kindlegen and kepubify support. It lets you keep your books in version control! It can watch your current epub file that you're editing and run epubmake on save.

Version 0.0.2
Source code on github

DiapDealer 12-16-2016 10:44 AM

Thanks for the contribution to improve the Sigil experience! I'll see it gets added to the plugin index.

Leonatus 01-10-2017 01:22 PM

Each time I run the plugin, I get this error:
Code:

TypeError: sequence item 1: expected a bytes-like object, str found
Error: sequence item 1: expected a bytes-like object, str found

.
Did I misunderstand something?
Sigil v. 0.9.7, Windows 10, 32 bit.

Doitsu 01-10-2017 01:53 PM

Quote:

Originally Posted by Leonatus (Post 3456126)
Each time I run the plugin, I get this error:
Code:

TypeError: sequence item 1: expected a bytes-like object, str found
Error: sequence item 1: expected a bytes-like object, str found

.
Did I misunderstand something?
Sigil v. 0.9.7, Windows 10, 32 bit.

I'm getting the same error message for certain commercial epubs. It looks like there's a bug in the plugin code. Until the author releases an official bugfix try the following:

1. Locate the Kepub Plugin folder (Edit > Preferences > Peferences Location).
2. Open kepubify.py and locate the following line:

Code:

root = re.sub(b'<p[^>/]*/>', '<p></p>', root).decode('utf-8')
3. Change it to:

Code:

root = re.sub(b'<p[^>/]*/>', b'<p></p>', root).decode('utf-8')
This should fix the issue.

JSWolf 01-10-2017 02:57 PM

Have a look at the Calibre plugin that converts to kepub and make sure your works the same.

Leonatus 01-10-2017 03:49 PM

@Doitsu: Works! Great! Thank you!:2thumbsup
@JSWolf: What I wanted to have a look at is whether the plugin renders a "real" kepub with the effect that the kepub specialities would be assigned to the book, but this the plugin doesn't seem to afford. Adding it to Calibre renders an epub as input format; substantial changes seem not to take place.

BetterRed 01-10-2017 04:15 PM

@Leonatus - JSWolf presumably had this calibre plugin in mind ==>> [Conversion Output] KePub Output Plugin

According to the first post for this plugin, it is based on that calibre plugin, which could mean it inherits from the calibre plugin, or the calibre plugin was hacked to create this plugin. The calibre plugin was last updated on June 26 2016, this plugin went to air in December of 2016 . . .

BR

Leonatus 01-11-2017 03:20 AM

Quote:

Originally Posted by BetterRed (Post 3456209)
@Leonatus - JSWolf presumably had this calibre plugin in mind ==>> [Conversion Output] KePub Output Plugin

Yes, I know this plugin. The point for my curiosity has been that, converting epub to kepub in calibre, destroys a lot of formatting that I have assigned to the epub, such as ignored fonts, and I only wanted to have a look if the Sgil plugin would behave a bit differently.

Doitsu 01-11-2017 04:10 AM

Quote:

Originally Posted by Leonatus (Post 3456475)
Yes, I know this plugin. The point for my curiosity has been that, converting epub to kepub in calibre, destroys a lot of formatting that I have assigned to the epub, such as ignored fonts, and I only wanted to have a look if the Sgil plugin would behave a bit differently.

I don't have a Kobo, but, AFAIK, Kobos have two different rendering engines (RMSDK/ADE and ACCESS NetFront) and books with a .kepup.epub file extension will be rendered with the ACCESS NetFront epub3 rendering engine whose specs are available online.

I coudn't hurt to convert some of your books with KevinH's epub3 output plugin and test them on a Kobo (after changing the file extension to .kepub.epub).

If the rendering is mostly OK, you could do some research to find out what needs to be changed for Kobo readers and report your findings to the Calibre/Sigil Kepub plugin developers.

If it's only minor cosmetic changes that won't invalidate the epub3, KevinH might even be willing to add a Kobo postprocessing option to his epub3 plugin.

Leonatus 01-11-2017 05:27 AM

Thank you for your hints! In fact, I'm not thus keen on rendering my epubs as kepubs. there are advantages of the kepub mode - there are people who don't even like them, though - but there are also some problems that normally leave me to remain at the epub format. For example the hyphenation feature of Kobo doesn't work - at least for me, very reliable, there are many errors, whereas the epub-plugin of SauliusP (Calibre) is very good.
It was mere curiosity that lead me to test the new plugin.

JSWolf 01-11-2017 06:25 AM

Quote:

Originally Posted by Leonatus (Post 3456520)
For example the hyphenation feature of Kobo doesn't work - at least for me, very reliable, there are many errors, whereas the epub-plugin of SauliusP (Calibre) is very good.
It was mere curiosity that lead me to test the new plugin.

Hyphenate This! adds in soft hyphens which do not work well with ADE. If you want better hyphenation, then you need to either edit the settings in the existing hyphenation dictionary or use the one I posted at https://www.mobileread.com/forums/sh...d.php?t=252405.

So if you don't want kepub,why are you in this thread trying out the plugin to convert to kepub?

davidfor 01-11-2017 06:34 AM

Quote:

Originally Posted by Leonatus (Post 3456475)
Yes, I know this plugin. The point for my curiosity has been that, converting epub to kepub in calibre, destroys a lot of formatting that I have assigned to the epub, such as ignored fonts, and I only wanted to have a look if the Sgil plugin would behave a bit differently.

The Kepub Output plugin shouldn't be destroying anything. The plugin basically just calls the epub output plugin and then does another pass to add tge spans that the kepub format needs. For other things, it should be exactly the same as doing an epub-to-epub conversion.

Leonatus 01-11-2017 01:20 PM

Quote:

Originally Posted by JSWolf (Post 3456536)
So if you don't want kepub,why are you in this thread trying out the plugin to convert to kepub?

as I said, I wanted to look if the plugin shows a different behaviour, and - is it not allowed to be curious?
@Davifor: I made the experience that for example fonts that I had added in the epub (and there showed correctly) did not show on the device after converting the epub to kepub under Calibre. But this was a time ago, and things might have changed meanwhile. I'll give it a try once more, now that all deny my own experience.

JSWolf 01-11-2017 05:26 PM

Quote:

Originally Posted by Leonatus (Post 3456687)
as I said, I wanted to look if the plugin shows a different behaviour, and - is it not allowed to be curious?
@Davifor: I made the experience that for example fonts that I had added in the epub (and there showed correctly) did not show on the device after converting the epub to kepub under Calibre. But this was a time ago, and things might have changed meanwhile. I'll give it a try once more, now that all deny my own experience.

Did you select publisher default as the font in the font list?

jackie_w 01-11-2017 05:48 PM

@Leonatus,

There is another problem you might be running into. By default the Kobo has some internal CSS override code for kepubs which is different from the override used for standard epubs,
Code:

* { font-family: %1 !important; }
which tries to force the book to be displayed in the user-selected font on the Kobo.

The Kobo Patcher does have a 'fix' for this (patch_name = `Un-Force user font-family in KePubs`) for those (I'm one of them) who dislike the heavy-handed default override. There are 3 alternative replacements to choose from.
  • div,p{font-family:%1!important; }
  • body,p{font-family:%1!important;}
  • body{font-family:%1 !important; }
The last one emulates the much less agressive default override the Kobo uses for standard epubs.


All times are GMT -4. The time now is 08:34 PM.

Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.