Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 04-11-2020, 03:25 AM   #16
Doitsu
Grand Sorcerer
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: 5,584
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by carmenchu View Post
I have implemented a variant of your suggestion, and (I hope!) avoided the trouble of a void "tags": "", getting the "tags" preferences obliterated on next run.
Unfortunately,
Code:
ttags = [True,prefs['tags'].split(',')][len(prefs['tags']) > 0 or 0] # evaluates to 1|0 for tags|no tags
doesn't work for empty strings. Since it was my idea anyway, simply remove the part that checks for empty strings.

Quote:
Originally Posted by carmenchu View Post
It's an option which I wouldn't recommend, save for report purposes: one can achieve the same result by a simple search & replace of class="calibre\d*"
Indeed. Maybe it isn't a good idea to have such an option.

Quote:
Originally Posted by carmenchu View Post
By the way, is there a simple way of getting the list of tags ordered? It would be easier to read and edit, but I can't get it done...
The built-in sort() function should also work for lists.

BTW, one other free Python book I can highly recommend is Automate the Boring Stuff with Python by Al Sweigart, which is available online and as a paid e-book.
Doitsu is offline   Reply With Quote
Old 04-11-2020, 12:54 PM   #17
carmenchu
Groupie
carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.
 
Posts: 183
Karma: 266070
Join Date: Dec 2010
Device: Win7,Win10,Lubuntu,smartphone
Well, attached is a new version, with:
- Option 'no tags' removed--it couldn't even be reported, lacking a list of tags for reference.
- Added a message (Qt) with buttons to choose on the fly if run only for reports (default -> OK) or to apply the changes (Cancel).
That would be useful before choosing to add/remove tags from preferences.
- Changed the versioning: this is v1_0, (implicitly making previous ones 0_x)
- Automatically sort the tag list (easier to inspect/edit), besides trying to ensure that it works.
Unfortunately, as it MUST be a comma-separated list, without spaces, the code is quite clumsy. A less unwieldy alternative would be appreciated.
Spoiler:
Code:
# protect editable string from mistype
def sanitize(string):
    if string != (' '):
        string = string.replace(' ','')
        string = string.replace(',,',',')
        string = string.lower()
        lstring = string.split(',')
        ostring = sorted(lstring)[0]
        for s in sorted(lstring)[1:]: # list of comma-separated strings
            ostring = ostring + "," + s
        # MUST be list of words(=tag names) comma-separated & without spaces
        string = ostring.replace(' ','')
    else:
        string = ' ' # Avoid bk.savePrefs(prefs) deleting the "tags" entry?--general havoc
    return string

* Query: are buttons of the message easy to understand, o rather counter-intuitive?

Last edited by carmenchu; 04-11-2020 at 03:34 PM.
carmenchu is offline   Reply With Quote
Old 04-11-2020, 01:35 PM   #18
Doitsu
Grand Sorcerer
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: 5,584
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by carmenchu View Post
Unfortunately, as it MUST be a comma-separated list, without spaces, the code is quite clumsy. A less unwieldy alternative would be appreciated.
Actually, you can save Python lists in the preference file.

Quote:
Originally Posted by carmenchu View Post
Query: are buttons of the message easy to understand, o rather counter-intuitive?
I'd simply use Yes and No to avoid confusion.

Code:
    msg.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
    testmode = [0,1][msg.exec_()== QMessageBox.Yes]

Last edited by Doitsu; 04-11-2020 at 02:39 PM.
Doitsu is offline   Reply With Quote
Old 04-11-2020, 02:33 PM   #19
carmenchu
Groupie
carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.
 
Posts: 183
Karma: 266070
Join Date: Dec 2010
Device: Win7,Win10,Lubuntu,smartphone
Quote:
I'd simply use Yes and No to avoid confusion.

Code:
    msg.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
    testmode = [0,1][msg.exec_()== QMessageBox.Yes]
A ton of thanks: works fine.
And, BTW, is there an equally simple way to substite the default icon of the message box (quite horrid, at least in my win10) with the plug-in icon, for instance?
If yes, I would wait to update the upload...
*Query*: uploading a new file with the name, would result in updating the previous attachment, or must one attach again? My ignorance

Quote:
Originally Posted by Doitsu View Post
Actually, you can save Python lists in the preference file.
Good to know: but think of the irritation of having to manually add 3 more tags to 'a','br','b',...
carmenchu is offline   Reply With Quote
Old 04-11-2020, 03:23 PM   #20
Doitsu
Grand Sorcerer
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: 5,584
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by carmenchu View Post
And, BTW, is there an equally simple way to substite the default icon of the message box (quite horrid, at least in my win10) with the plug-in icon, for instance?
Unfortunately, I can't help you with that. Maybe @DiapDealer or @KevinH know how to do this.

Quote:
Originally Posted by carmenchu View Post
*Query*: uploading a new file with the name, would result in updating the previous attachment, or must one attach again? My ignorance
No idea. I usually attach files with different file names.
Doitsu is offline   Reply With Quote
Old 04-11-2020, 03:30 PM   #21
carmenchu
Groupie
carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.
 
Posts: 183
Karma: 266070
Join Date: Dec 2010
Device: Win7,Win10,Lubuntu,smartphone
Thanks! Attaching the corrected version.
Attached Files
File Type: zip RedundantI_v1_0.zip (4.4 KB, 609 views)
carmenchu is offline   Reply With Quote
Old 05-14-2020, 01:44 PM   #22
AlanHK
Guru
AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.
 
AlanHK's Avatar
 
Posts: 668
Karma: 929286
Join Date: Apr 2014
Device: PW-3, iPad, Android phone
Quote:
Originally Posted by carmenchu View Post
# get all i,b,small,sup,sub,br,a,li tags with class='*calibre*' (containing all those characters, in fact)

So this strips <i class="calibreX"> to <i>?

Occasionally, I see cases where the style makes it bold italic, not just italic.

Generally that seems to be set on words in a longer bold passage:

Code:
<p><b>Words in bold</b><i class=CalibreX">words bold italic</i><b> More bold</b></p>
So it's a good idea to inspect the definitions before running such a conversion.
AlanHK is offline   Reply With Quote
Old 05-14-2020, 02:40 PM   #23
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 74,037
Karma: 129333114
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by AlanHK View Post
So this strips <i class="calibreX"> to <i>?

Occasionally, I see cases where the style makes it bold italic, not just italic.

Generally that seems to be set on words in a longer bold passage:

Code:
<p><b>Words in bold</b><i class=CalibreX">words bold italic</i><b> More bold</b></p>
So it's a good idea to inspect the definitions before running such a conversion.
I have never seen an <i class="calibreX"> where you cannot remove the class and leave just <i>.
JSWolf is offline   Reply With Quote
Old 05-14-2020, 04:48 PM   #24
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 35,507
Karma: 145557716
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Forma, Clara HD, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Quote:
Originally Posted by JSWolf View Post
I have never seen an <i class="calibreX"> where you cannot remove the class and leave just <i>.
I've seen a couple of times where calibre has left bold and italic inside either a <b> or <i> tag. Relatively rare and a quick search will find them.
DNSB is offline   Reply With Quote
Old 06-01-2020, 10:35 PM   #25
AlanHK
Guru
AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.
 
AlanHK's Avatar
 
Posts: 668
Karma: 929286
Join Date: Apr 2014
Device: PW-3, iPad, Android phone
Quote:
Originally Posted by carmenchu View Post
Thanks! Attaching the corrected version.
Can I suggest you update the first post in the thread so it always has the latest version.

Wishlist for other "fixes":

Calibre seems to always name the cover "titlepage.xhtml", which is really grating to me, since it's not the title page. I always rename it to cover.xhtml (except if there is already a cover.xhtml). Can that be an option?

Seems that Calibre always adds "display: block;" to style definitions. Can that be removed optionally?

The <body> tag is invariably <body class="calibre">
Can that be made just <body> and the style .calibre renamed "body"?


Quote:
Originally Posted by JSWolf View Post
I have never seen an <i class="calibreX"> where you cannot remove the class and leave just <i>.
Yeah, I just made it up. You got me.

Has anyone ever asked Kovid why Calibre does these redundant styles? Does Calibre still do it?

It's not hard to fix by S&R, but it does get tedious. But I can't see the structure of the file until I clean away all the cruft.

Last edited by AlanHK; 06-01-2020 at 11:30 PM.
AlanHK is offline   Reply With Quote
Old 05-08-2023, 11:15 PM   #26
sadhu44
Member
sadhu44 began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Sep 2012
Location: Sri Lanka
Device: none
Tried to add the redundant1 plug-n, but got this error: InvalidPlugin:The plugin in ... redundanti8_v1.zip is invalid. It does not contain a top-level _init_.py file.
sadhu44 is offline   Reply With Quote
Old 05-09-2023, 09:16 AM   #27
KevinH
Sigil Developer
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: 7,654
Karma: 5433388
Join Date: Nov 2009
Device: many
Quote:
Originally Posted by sadhu44 View Post
Tried to add the redundant1 plug-n, but got this error: InvalidPlugin:The plugin in ... redundanti8_v1.zip is invalid. It does not contain a top-level _init_.py file.
This plugin is for Sigil not calibre.
KevinH is offline   Reply With Quote
Old 05-09-2023, 09:21 AM   #28
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: 27,553
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by sadhu44 View Post
It does not contain a top-level _init_.py file.
And it shouldn't. Sigil plugins don't contain a top-level __init__.py file. Note that you also should not unzip, or alter the plugin archive in any way--including renaming the archive. Some browser download "helpers" rename files automatically.

EDIT: Ahh... as Kevin noted, it does indeed seem as if you are trying to install a Sigil plugin into calibre. That definitely will not work.
DiapDealer is offline   Reply With Quote
Old 05-09-2023, 12:07 PM   #29
sadhu44
Member
sadhu44 began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Sep 2012
Location: Sri Lanka
Device: none
wups. Sorry, fellas.
sadhu44 is offline   Reply With Quote
Old 09-24-2023, 05:30 AM   #30
arcchancellor
Junior Member
arcchancellor began at the beginning.
 
arcchancellor's Avatar
 
Posts: 4
Karma: 10
Join Date: Jan 2023
Device: none
Is it possible to add an option in RedundantI to add more Calibre tags like body, headers, metadata and dc:identifier?
arcchancellor is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Pseudo classes to be deleted as unused classes Leonatus Sigil 2 09-23-2018 09:12 AM
Calibre conversion adding classes and screwing the layout? 1v4n0 Conversion 6 01-29-2015 12:57 PM
Calibre Inserting Its Own CSS Classes Xopher H Conversion 2 08-02-2011 10:21 PM
possible to change classes name,id,stylename that generated by calibre? hard13 Conversion 2 02-24-2011 09:23 PM
keeping or removing a div with multiple classes JohnsonZA Recipes 1 09-25-2010 10:33 AM


All times are GMT -4. The time now is 06:16 PM.


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