![]() |
[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? |
What is wrong with a simple search and replace?
|
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> |
But you have a plugin for calibre editor which does exactly that (and more).
|
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. ;) |
In Calibre's eBook editor, "remove unused CSS rules" also removes classes from the xHTML that are not used.
|
There you go.
|
Quote:
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 |
Quote:
Code:
class="first second"Quote:
|
Quote:
|
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. |
Quote:
|
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. |
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.
|
Quote:
|
| All times are GMT -4. The time now is 08:54 PM. |
Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.