09-19-2016, 02:40 PM | #1 |
Member
Posts: 16
Karma: 1422
Join Date: Mar 2016
Device: none
|
[REQ] A plugin that delete class in the chapter
Hi all, I have a request, sometime I must re-edit an old epub or a epub give me by someone and I find the code full of class and span, for example purely coincidental: calibre1, calibre2, calibre3, calibre52,...
Normally if there isn't too much editing I copy the text like a txt in a new epub but sometime I cant do it so I must delete them whit the find. I use CSS Remove Unused Selector that delete the unused class in css (very usefull), there is a possibility to delete, by a similar menù, the class in the chapter? |
09-19-2016, 03:30 PM | #2 |
Wizard
Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
|
What is wrong with a simple search and replace?
|
Advert | |
|
09-19-2016, 04:51 PM | #3 |
Evangelist
Posts: 417
Karma: 6913952
Join Date: Aug 2013
Location: Hamden, CT
Device: Kindle Paperwhite (11th gen), Scribe
|
With just a regex, there's nothing simple about a search for a tag with a specific "class=" and then removing that tag (and it's closing tag). For example, build a general-purpose regex that successfully deletes the tag with class "deleteme", along with the matching closing tag:
Code:
<span class="keep01">Here <span class="deleteme">is <span class="alsokeep">the</span> text <span class="dontdelete">in the</span> book</span> that should all remain intact.</span> |
09-19-2016, 04:53 PM | #4 |
Grand Sorcerer
Posts: 6,233
Karma: 11768331
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
But you have a plugin for calibre editor which does exactly that (and more).
|
09-19-2016, 05:08 PM | #5 | ||
Grand Sorcerer
Posts: 27,549
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Quote:
Quote:
By the way: both the TagMechanic plugin for Sigil, and "Diap's Editing Toolbag" for calibre make it trivial to successfully remove the tag with the class "deleteme" (along with the matching closing tag), per your example. Last edited by DiapDealer; 09-19-2016 at 05:19 PM. |
||
Advert | |
|
09-19-2016, 05:28 PM | #6 |
Resident Curmudgeon
Posts: 73,983
Karma: 128903378
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
In Calibre's eBook editor, "remove unused CSS rules" also removes classes from the xHTML that are not used.
|
09-19-2016, 05:37 PM | #7 |
Grand Sorcerer
Posts: 27,549
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
There you go.
|
09-20-2016, 06:54 PM | #8 | ||
Member
Posts: 16
Karma: 1422
Join Date: Mar 2016
Device: none
|
When you open a css and read .calibre92 you want a button that can delete every calibre in the book in one click, and yes I have already search and replace it 92 times with a very great happyness, so I hope for the next time they send me this thing I have something more faster to correct them
Quote:
Quote:
I find something a little extreme with smoothRemove plugin that can resolve (delete every class and span but not i and b), with TagMechanic convert the class in italic and bold and the rest in the mincer of smoothRemove Last edited by Auramazda; 09-20-2016 at 07:44 PM. |
||
09-20-2016, 08:45 PM | #9 | ||
Evangelist
Posts: 417
Karma: 6913952
Join Date: Aug 2013
Location: Hamden, CT
Device: Kindle Paperwhite (11th gen), Scribe
|
Quote:
Code:
class="first second" Quote:
|
||
09-20-2016, 08:58 PM | #10 | |
Grand Sorcerer
Posts: 27,549
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Quote:
|
|
09-21-2016, 02:58 AM | #11 | |
Wizard
Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
|
Quote:
So, search for 'class=".calibre\d+"' and replace it by nothing. Then run TagMechanic and remove empty span. Two actions only. Another option could be is to import the ePUB into Word, do some cleaning/fixing if needed (check quotation marks for example) and then export the ePUB from Word. That would also remove the .calibre classes if you want. It is also possible to keep the classes you do want. I have to say that removing all the calibre classes in one go is tricky in all cases. You could easily get rid of formatting that way that you don't want to loose. That is the problem with a generic class name, you don't know what it is about. It is however a side-effect from conversion that usually cannot be prevented. I would personally never remove all calibre classes in one go. |
|
09-21-2016, 10:05 AM | #12 | |
Well trained by Cats
Posts: 29,802
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
|
|
09-21-2016, 10:14 AM | #13 | |
Resident Curmudgeon
Posts: 73,983
Karma: 128903378
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
What I do it go through the classes and replacement with the code I want and the names I want so I'll have a better idea of what the class does by the name. A class name of calibre12 on it's own doesn't say that it does. |
|
09-21-2016, 10:17 AM | #14 |
Resident Curmudgeon
Posts: 73,983
Karma: 128903378
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
If you have a class like say <span class="doesnotexist"> and you load the ePub into Calibre's editor, you can use the tool to remove unused CSS and it will remove the class from the span if the class is not in the CSS. Then you can use the modify ePub plugin to remove empty spans.
|
09-21-2016, 10:57 AM | #15 | |
Grand Sorcerer
Posts: 27,549
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Quote:
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Aura H2O MicroSDHC card class 4 or class 10? | chipro12 | Kobo Reader | 5 | 07-04-2015 02:24 AM |
Using "Delete Duplicates" Plugin | Beemerang | Plugins | 3 | 10-30-2014 02:04 AM |
Is there a plugin that will search a library to delete the ORIGINAL_EPUB files | LadyKate | Library Management | 4 | 11-09-2013 09:02 PM |
PRS-650 SD Card Importance? SDHC, SDHC Class 4, Class 10 etc is it important | Renji | Sony Reader | 11 | 12-03-2011 12:30 PM |
Delete files in PC not equal to delete in Sony reader 505 | sheilalayoli | Sony Reader | 5 | 07-12-2009 03:13 PM |