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 04-11-2020, 03:25 AM   #16
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,950
Karma: 16800001
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 is a name known to allcarmenchu is a name known to allcarmenchu is a name known to allcarmenchu is a name known to allcarmenchu is a name known to allcarmenchu is a name known to allcarmenchu is a name known to allcarmenchu is a name known to allcarmenchu is a name known to allcarmenchu is a name known to allcarmenchu is a name known to all
 
Posts: 169
Karma: 159672
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
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,950
Karma: 16800001
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 is a name known to allcarmenchu is a name known to allcarmenchu is a name known to allcarmenchu is a name known to allcarmenchu is a name known to allcarmenchu is a name known to allcarmenchu is a name known to allcarmenchu is a name known to allcarmenchu is a name known to allcarmenchu is a name known to allcarmenchu is a name known to all
 
Posts: 169
Karma: 159672
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
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,950
Karma: 16800001
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 is a name known to allcarmenchu is a name known to allcarmenchu is a name known to allcarmenchu is a name known to allcarmenchu is a name known to allcarmenchu is a name known to allcarmenchu is a name known to allcarmenchu is a name known to allcarmenchu is a name known to allcarmenchu is a name known to allcarmenchu is a name known to all
 
Posts: 169
Karma: 159672
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, 48 views)
carmenchu is offline   Reply With Quote
Old 05-14-2020, 01:44 PM   #22
AlanHK
Fanatic
AlanHK is slicker than a case of WD-40AlanHK is slicker than a case of WD-40AlanHK is slicker than a case of WD-40AlanHK is slicker than a case of WD-40AlanHK is slicker than a case of WD-40AlanHK is slicker than a case of WD-40AlanHK is slicker than a case of WD-40AlanHK is slicker than a case of WD-40AlanHK is slicker than a case of WD-40AlanHK is slicker than a case of WD-40AlanHK is slicker than a case of WD-40
 
AlanHK's Avatar
 
Posts: 528
Karma: 73392
Join Date: Apr 2014
Device: PW-3, 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: 58,017
Karma: 53003081
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Aura H2O, PRS-650, PRS-T1, nook STR, iPad 4, iPhone SE 2020, 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 online now   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: 7,850
Karma: 34623437
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Forma, Clara HD, Nexus 7 HD, iPad Pro, 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 online now   Reply With Quote
Old 06-01-2020, 10:35 PM   #25
AlanHK
Fanatic
AlanHK is slicker than a case of WD-40AlanHK is slicker than a case of WD-40AlanHK is slicker than a case of WD-40AlanHK is slicker than a case of WD-40AlanHK is slicker than a case of WD-40AlanHK is slicker than a case of WD-40AlanHK is slicker than a case of WD-40AlanHK is slicker than a case of WD-40AlanHK is slicker than a case of WD-40AlanHK is slicker than a case of WD-40AlanHK is slicker than a case of WD-40
 
AlanHK's Avatar
 
Posts: 528
Karma: 73392
Join Date: Apr 2014
Device: PW-3, 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
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 05:05 PM.


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