View Single Post
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: 28,701
Karma: 205039118
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