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 09-19-2016, 02:40 PM   #1
Auramazda
Member
Auramazda is no ebook tyro.Auramazda is no ebook tyro.Auramazda is no ebook tyro.Auramazda is no ebook tyro.Auramazda is no ebook tyro.Auramazda is no ebook tyro.Auramazda is no ebook tyro.Auramazda is no ebook tyro.Auramazda is no ebook tyro.Auramazda is no ebook tyro.
 
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?
Auramazda is offline   Reply With Quote
Old 09-19-2016, 03:30 PM   #2
Toxaris
Wizard
Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.
 
Toxaris's Avatar
 
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?
Toxaris is offline   Reply With Quote
Advert
Old 09-19-2016, 04:51 PM   #3
nabsltd
Evangelist
nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.
 
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>
This operation is trivial with a real HTML editor (I use Expression Web), but Sigil (and Calibre) don't have anything that can do this, and that's a simple operation compared to what you can do with a real editor.
nabsltd is offline   Reply With Quote
Old 09-19-2016, 04:53 PM   #4
Terisa de morgan
Grand Sorcerer
Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.
 
Terisa de morgan's Avatar
 
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).
Terisa de morgan is online now   Reply With Quote
Old 09-19-2016, 05:08 PM   #5
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,549
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by Terisa de morgan View Post
But you have a plugin for calibre editor which does exactly that (and more).
There's a Sigil version of the very same plugin.

Quote:
Originally Posted by nabsltd View Post
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>
This operation is trivial with a real HTML editor (I use Expression Web), but Sigil (and Calibre) don't have anything that can do this, and that's a simple operation compared to what you can do with a real editor.
First off: you're right. Regex is not the best tool for removing tags based on attribute values. But I don't think that's what the OP was asking for (nor what Toxaris was suggesting using regex for). The OP is asking for something that removes classes (classes that are no longer being used by CSS) from attribute strings. For this purpose, regex is quite safe/sufficient (as Toxaris noted).

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.
DiapDealer is offline   Reply With Quote
Advert
Old 09-19-2016, 05:28 PM   #6
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: 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.
JSWolf is offline   Reply With Quote
Old 09-19-2016, 05:37 PM   #7
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,549
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
There you go.
DiapDealer is offline   Reply With Quote
Old 09-20-2016, 06:54 PM   #8
Auramazda
Member
Auramazda is no ebook tyro.Auramazda is no ebook tyro.Auramazda is no ebook tyro.Auramazda is no ebook tyro.Auramazda is no ebook tyro.Auramazda is no ebook tyro.Auramazda is no ebook tyro.Auramazda is no ebook tyro.Auramazda is no ebook tyro.Auramazda is no ebook tyro.
 
Posts: 16
Karma: 1422
Join Date: Mar 2016
Device: none
Quote:
Originally Posted by Toxaris View Post
What is wrong with a simple search and replace?
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:
Originally Posted by DiapDealer View Post
First off: you're right. Regex is not the best tool for removing tags based on attribute values. But I don't think that's what the OP was asking for (nor what Toxaris was suggesting using regex for). The OP is asking for something that removes classes (classes that are no longer being used by CSS) from attribute strings. For this purpose, regex is quite safe/sufficient (as Toxaris noted).
Yes this is my dream

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.
I have missed this plugin, is a great tool (I will use it in the near future), but is a manually tool and I will always have to write all 92 calibre class to delete them.

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.
Auramazda is offline   Reply With Quote
Old 09-20-2016, 08:45 PM   #9
nabsltd
Evangelist
nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.
 
Posts: 417
Karma: 6913952
Join Date: Aug 2013
Location: Hamden, CT
Device: Kindle Paperwhite (11th gen), Scribe
Quote:
Originally Posted by DiapDealer View Post
First off: you're right. Regex is not the best tool for removing tags based on attribute values. But I don't think that's what the OP was asking for (nor what Toxaris was suggesting using regex for). The OP is asking for something that removes classes (classes that are no longer being used by CSS) from attribute strings.
I didn't get that from the post, as he was asking to delete unused stuff from the HTML file. If you just want to delete an attribute on an HTML element, then it's not too hard (although you have to account for things like
Code:
class="first second"
That might leave you with a span that does nothing effective, but if it has other attributes, it won't be deleted as "empty" by the various tools. In other words, I couldn't figure out how he ended up with attributes that do nothing so they can be deleted safely, so I assumed he meant deleting the span/div/etc.

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.
Definitely a good start, but I'm spoiled by Expression Web and the selection process it has for elements to modify (with/without attribute, containing/not containing text/tag, inside/not inside tag, with infinite nesting of these rules) plus what it can do (replace tag/contents, add before/after start/end tag, remove tag/contents, change tag, change/remove attribute), and all of it can be regexed.
nabsltd is offline   Reply With Quote
Old 09-20-2016, 08:58 PM   #10
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,549
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by nabsltd View Post
Definitely a good start, but I'm spoiled by Expression Web and the selection process it has for elements to modify (with/without attribute, containing/not containing text/tag, inside/not inside tag, with infinite nesting of these rules) plus what it can do (replace tag/contents, add before/after start/end tag, remove tag/contents, change tag, change/remove attribute), and all of it can be regexed.
By all means, stick with what you're comfortable with. Sigil is never going to be a full-featured html editor. There's no need to reinvent the wheel after all. Plenty of those already exist if you require that sort of ability.
DiapDealer is offline   Reply With Quote
Old 09-21-2016, 02:58 AM   #11
Toxaris
Wizard
Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.
 
Toxaris's Avatar
 
Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
Quote:
Originally Posted by Auramazda View Post
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

...

I have missed this plugin, is a great tool (I will use it in the near future), but is a manually tool and I will always have to write all 92 calibre class to delete them.

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
If you use for example .calibre\d+ you would catch all classes. If you do not use the actual tag, it will leave it there. For example spans would become empty and can easily be removed in one go with the plugin from DiapDealer.

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.
Toxaris is offline   Reply With Quote
Old 09-21-2016, 10:05 AM   #12
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
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:
Originally Posted by Toxaris View Post
If you use for example .calibre\d+ you would catch all classes. If you do not use the actual tag, it will leave it there. For example spans would become empty and can easily be removed in one go with the plugin from DiapDealer.

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.
You can use that REGEX (calibre\d+) within Diaps Tag tool. Just tick the REGEX box at the end if the pattern
theducks is online now   Reply With Quote
Old 09-21-2016, 10:14 AM   #13
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: 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:
Originally Posted by Auramazda View Post
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
And if you remove ever Calibre named class, you will have no idea what those classes did. You may be able to guess at some and get it correct, but no way you'd get them all correct.

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.
JSWolf is offline   Reply With Quote
Old 09-21-2016, 10:17 AM   #14
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: 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.
JSWolf is offline   Reply With Quote
Old 09-21-2016, 10:57 AM   #15
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,549
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by JSWolf View Post
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.
I let the first few instances go, Jon (because information is always good), but it's now time to stop promoting calibre solutions in a discussion thread about a Sigil plugin request. That there are ways to accomplish the OP's request in both Sigil and calibre have been established and noted. Now it's time to stay on topic (Sigil), or bow out.
DiapDealer is offline   Reply With Quote
Reply


Forum Jump

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


All times are GMT -4. The time now is 04:25 PM.


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