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 11-01-2014, 01:07 PM   #1
kbanelas
Member
kbanelas can extract oil from cheesekbanelas can extract oil from cheesekbanelas can extract oil from cheesekbanelas can extract oil from cheesekbanelas can extract oil from cheesekbanelas can extract oil from cheesekbanelas can extract oil from cheesekbanelas can extract oil from cheese
 
Posts: 13
Karma: 1000
Join Date: Oct 2014
Device: bq cervantes
smoothRemove_v010 plugin for Sigil

Hi to everybody!!
I have the pleasure of introduce to you this simple plugin: smoothRemove in its version 0.1.0.

This plugin is designed to help you when you need a complete remove formatting with the exception of that the code will keep some tags. So if you do a copy/paste from a WYSIWYG to Sigil then you could run this plugin and make remove formatting but maintaining bold, italic, underline texts and headings, paragraphs and lists.

Disclaimer: I hope it will be usefull but it isn't a perfect code, it's a beta version. So save all your ePub in Sigil before running this plugin.

Credits: By kbanelas. But I want to thank to everybody who supported me, overall, because, they never thought being wasting time to talk to me. They just trusted me. Thanks again.

System requirements

Before installing this plugin, please make sure that the system requirements are met. To be able to use this plugin, you'll need Python 2.7.x
To find out whether Python 2.7.x is installed, enter the following command in a terminal/command prompt window:

python -V (should display Python 2.7.x)


Installation

1. Select Manage Plugins from the Plugins menu. If the Python 2.7 text box is empty, click Auto to detect the path or Set to manually select the Python folder.
2. Click Add Plugin and select smoothRemove_v010.zip. This will install the plugin, which you can select via Plugins > edit> smoothRemove> Start.

How to use smoothRemove

1. Select the method:
a) All : for all file in the eBook
b) Some files: mark the files corresponding
Then press Apply. You will look the changes when press Quit.

ATTENTION: Don't use this plugin with the cover, so if you have one, don't select a complete smoothRemove, only select the files in that you are interested.

That's all.

Thanks.
Cheers!!
Attached Files
File Type: zip smoothRemove_v010.zip (1.9 KB, 2686 views)
kbanelas is offline   Reply With Quote
Old 11-01-2014, 03:05 PM   #2
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,659
Karma: 5433388
Join Date: Nov 2009
Device: many
Hi,

If there is a moderator around, would you please add this thread to the sticky Sigil Plugin Index so that it can be found by everyone.

Thanks,
KevinH is offline   Reply With Quote
Advert
Old 11-28-2016, 12:04 PM   #3
Crick
Junior Member
Crick began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Nov 2016
Device: none
can someone upgrade this plugin so that it can be use in the last version of Sigil?
Crick is offline   Reply With Quote
Old 11-28-2016, 12:40 PM   #4
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,553
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by Crick View Post
can someone upgrade this plugin so that it can be use in the last version of Sigil?
It will need to be modifed to work with Python 3. Support for Python 2.7-only plugins was dropped.

I can look to see what kind of effort it would take to port it, but I would prefer to wait for the original contributor to chime in first. If the plugin appears to be abandoned, we will, of course, accept updates from contributors.
DiapDealer is offline   Reply With Quote
Old 11-29-2016, 04:31 AM   #5
Doitsu
Grand Sorcerer
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: 5,584
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by DiapDealer View Post
I can look to see what kind of effort it would take to port it, but I would prefer to wait for the original contributor to chime in first.
The original contributor hasn't visited Mobileread in more than 2 years and is unlikely to provide an update. I tried to update the code myself, but I couldn't figure out how to change the class _init_ declaration for Python 3. (Apparently the syntax has changed in Python 3.)

@Crick: You might find the following plugins helpful:

TagMechanic (allows you to modify or delete attributes/tags )

RemoveInLineStyles (converts inline styles to CSS selectors)

cssRemoveUnusedSelectors (removes unused CSS selectors)

IMHO, TagMechanic will give you much more control over the tags that'll be deleted or modified. SmoothRemove is more like a sledgehammer.

@DiapDealer: Instead of updating the smoothRemove plugin It might make more sense to add a "nuclear option" to the TagMechanic plugin that'll remove all attributes that can be safely removed without making the HTML file invalid. (For example, it shouldn't remove the html xmlns attribute.)

Last edited by Doitsu; 11-29-2016 at 04:48 AM.
Doitsu is offline   Reply With Quote
Advert
Old 11-29-2016, 08:39 AM   #6
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,553
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
@Doitsu Thanks! I'll take a look. This plugin is not one I'm remotely familiar with. I'll see what makes the most sense (when I get some time).
DiapDealer is offline   Reply With Quote
Old 12-02-2016, 10:31 AM   #7
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,659
Karma: 5433388
Join Date: Nov 2009
Device: many
I looked at the plugin.py file. The Tk stuff will have to be updated but most of the real work is done in Remove which uses regular expressions to simply strip off all attributes from a specified set of tags inside a body tag.

If you don't have time, I would be happy to try to make a version that will work with both python2.7 and 3.4 so that the new version will still work for people using older Sigil versions that still support python 2.7.

Just let me know.

KevinH
KevinH is offline   Reply With Quote
Old 12-03-2016, 08:50 AM   #8
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,553
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
If you want to take a stab at it, then yes ... go ahead. If I did it, I'd probably wind up ignoring the 2.7 compatibility. I don't think I have a version of Sigil installed anywhere that I could even test 2.7 compatibility with anymore.

I do know there's a lot of imports that go unused in the plugin. I assume the creator had future plans they never got around to implementing.
DiapDealer is offline   Reply With Quote
Old 12-09-2016, 03:23 AM   #9
kbanelas
Member
kbanelas can extract oil from cheesekbanelas can extract oil from cheesekbanelas can extract oil from cheesekbanelas can extract oil from cheesekbanelas can extract oil from cheesekbanelas can extract oil from cheesekbanelas can extract oil from cheesekbanelas can extract oil from cheese
 
Posts: 13
Karma: 1000
Join Date: Oct 2014
Device: bq cervantes
If someone wants to update the plugin, there is no problem for me. I would do it myself but I do not have time.
I send you a nice greeting.
kbanelas is offline   Reply With Quote
Old 12-10-2016, 02:50 PM   #10
signum
Zealot
signum calls his or her ebook reader Vera.signum calls his or her ebook reader Vera.signum calls his or her ebook reader Vera.signum calls his or her ebook reader Vera.signum calls his or her ebook reader Vera.signum calls his or her ebook reader Vera.signum calls his or her ebook reader Vera.signum calls his or her ebook reader Vera.signum calls his or her ebook reader Vera.signum calls his or her ebook reader Vera.signum calls his or her ebook reader Vera.
 
Posts: 119
Karma: 64428
Join Date: Aug 2011
Device: none
Quote:
Originally Posted by KevinH View Post
I looked at the plugin.py file. The Tk stuff will have to be updated but most of the real work is done in Remove which uses regular expressions to simply strip off all attributes from a specified set of tags inside a body tag.

If you don't have time, I would be happy to try to make a version that will work with both python2.7 and 3.4 so that the new version will still work for people using older Sigil versions that still support python 2.7.

Just let me know.

KevinH
If you decide to proceed, I have some tiny corrections that enable smoothRemove to deal with < b >, < blockquote > and < i > correctly. As it stands, the "bold" tag doesn't get closed and blockquote is just deleted entirely. I forget what's wrong with the "italic" tag. I'll be watching my inbox here at least once a day.
signum is offline   Reply With Quote
Old 12-10-2016, 06:09 PM   #11
Doitsu
Grand Sorcerer
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: 5,584
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by signum View Post
If you decide to proceed, I have some tiny corrections that enable smoothRemove to deal with < b >, < blockquote > and < i > correctly. As it stands, the "bold" tag doesn't get closed and blockquote is just deleted entirely. I forget what's wrong with the "italic" tag. I'll be watching my inbox here at least once a day.
IMHO, the plugin author took some shortcuts and missed at least one typo. The relevant code is:

Code:
self.OPENTAG = ['<p','<b','<i','<u','<h1','<h2','<h3','<h4','<h5','<h6','<ol','<ul','<li','<body']
The highlighted expression matches <b> tags, but also all other tags that start with a b, e.g. <blockquote>.

Code:
self.CLOSETAG = ['</p>','</b>','</i>','</u>','</h1>','</h2>','</h3>','</h4>','</h5>','</h6>','</ol>','</ul>','</li>','</body>','</html>']
The closing right angle bracket of </b> is missing.

IMHO, pretty much everything that this plugin does, can be achieved by a simple regex search:

Find:<(p|b|i|u|h[1-6]|ol|ul|li|body) [^>]+>
Replace:<\1>

(My regex search string isn't perfect either, but it's slightly more robust than the one used in the plugin code.)
Doitsu is offline   Reply With Quote
Old 12-11-2016, 02:50 AM   #12
roger64
Wizard
roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.
 
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
Quote:
Originally Posted by Doitsu View Post

IMHO, pretty much everything that this plugin does, can be achieved by a simple regex search:

Find:<(p|b|i|u|h[1-6]|ol|ul|li|body) [^>]+>
Replace:<\1>

(My regex search string isn't perfect either, but it's slightly more robust than the one used in the plugin code.)
Thanks for it. For terminally ill EPUBs...
Why do you spare spans of that pruning treatment? (and divs BTW)
roger64 is offline   Reply With Quote
Old 12-11-2016, 03:18 AM   #13
Doitsu
Grand Sorcerer
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: 5,584
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by roger64 View Post
Why do you spare spans of that pruning treatment? (and divs BTW)
I "spared" them because I tried to reproduce the functionality of the plugin. Of course you're free to add or remove tags. Simply add the tag name and a pipe symbol (|). For example:

Find:<(div|span|p|b|i|u|h[1-6]|ol|ul|li|body) [^>]+>

If you ever consider using this regex, might want to create a backup copy and run KevinH's RemoveInLineStyles plugin first.
This will add the original inline styles to the main stylesheet and allows you to add them back via class attributes if you find out that some of them were actually needed.

Last edited by Doitsu; 12-11-2016 at 03:21 AM.
Doitsu is offline   Reply With Quote
Old 01-27-2017, 02:47 AM   #14
ebookreadr
Enthusiast
ebookreadr began at the beginning.
 
Posts: 26
Karma: 10
Join Date: Dec 2012
Device: nook
Quote:
Originally Posted by Doitsu View Post
. . .Simply add the tag name and a pipe symbol (|). For example:

Find:<(div|span|p|b|i|u|h[1-6]|ol|ul|li|body) [^>]+>
Sometimes the books I've bought have span class items many times, breaking up sentences etc. Below is an example from a B&N book. The nook did not display the paragraphs correctly and they ended up giving me a credit for the book.

Quote:
<p class="pubitCssCls19"><span class="pubitCssCls18">But the one thing that isn’t strange is that anyone that does happen to notice, probably only has it occupy his or her attention for a few moments</span><span class="pubitCssCls18">. They might wonder why someone would behave like this. They might wonder about the circumstances that</span> <span class="pubitCssCls18">could have</span> <span class="pubitCssCls18">lead up to this point in time. They might spend a few seconds wondering about this</span> <span class="pubitCssCls18">before</span> <span class="pubitCssCls18">they go back to gawking at the sights, or</span> <span class="pubitCssCls18">before they continue</span> <span class="pubitCssCls18">rushing to wherever they’re going. Before they</span> <span class="pubitCssCls18">simply</span> <span class="pubitCssCls18">move on.</span>. . .</p>
After the find: <(div|span|p|b|i|u|h[1-6]|ol|ul|li|body) [^>]+>
replace: <\1>
I end up with a bunch of <span> & </span> left over as seen below:

Quote:
<p><span>But the one thing that isn’t strange is that anyone that does happen to notice, probably only has it occupy his or her attention for a few moments</span><span>. They might wonder why someone would behave like this. They might wonder about the circumstances that</span> <span>could have</span> <span>lead up to this point in time. They might spend a few seconds wondering about this</span> <span>before</span> <span>they go back to gawking at the sights, or</span> <span>before they continue</span> <span>rushing to wherever they’re going. Before they</span> <span>simply</span> <span>move on.</span> <span>. . .</P>
I also loose any span class that is configured for italics.
SmoothRemove used to remove the extras, but leave italics and bolds. SmoothRemove will not install on my Windows 10 x64 computer - it says it is not compatible with the OS.
Any further ideas? (please note that I know the basics, but am not an expert at Sigil/CSS coding)
Thanks for your help.

Last edited by ebookreadr; 01-27-2017 at 02:50 AM.
ebookreadr is offline   Reply With Quote
Old 01-27-2017, 03:47 AM   #15
Doitsu
Grand Sorcerer
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: 5,584
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by ebookreadr View Post
Any further ideas? (please note that I know the basics, but am not an expert at Sigil/CSS coding).
My regex is only useful for books whose formatting can't be salvaged. You could simply remove span from the regex:

Code:
<(div|p|b|i|u|h[1-6]|ol|ul|li|body) [^>]+>
and then handle the remaining spans with TagMechanic.
Doitsu is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
epubcheck plugin for Sigil Doitsu Plugins 502 02-20-2024 06:58 AM
kindlegen plugin for Sigil Doitsu Plugins 169 02-16-2024 06:48 AM
[Plugin] PunctuationSmarten Sigil plugin DiapDealer Plugins 138 07-11-2023 11:22 AM
[Plugin] KindleImport Sigil plugin DiapDealer Plugins 187 07-04-2022 10:11 AM
Sigil Plugin Index Thasaidon Plugins 0 10-04-2014 07:41 AM


All times are GMT -4. The time now is 11:55 AM.


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