Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Sigil > Plugins

Notices

Reply
 
Thread Tools Search this Thread
Old 07-04-2017, 06:36 AM   #1
slowsmile
Witchman
slowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of light
 
Posts: 211
Karma: 12036
Join Date: May 2013
Location: Philippines
Device: Android S5
[Plugin] CustomCleanerPlus

An epub-specific custom cleaning utility for both epubs and imported html docs.

Requirements
Plugin Type: Edit
MIT Licence(OSI)
Minimum Sigil requirement: v0.9.3 or higher
Python Requirements: Python 3.4+ (Bundled or External)
OS Requirements: Windows, OSX or Linux
*** Tested on Windows 7, 8 & 10, OSX and Linux ***
Current Version: "0.2.9"

Installation
* Select Manage Plugins from the Plugins menu. In the dialog box, select either the Bundled Python or the External Python(Python 3.4+ should be installed on your computer to run this plugin externally).

* Click Add Plugin and select CustomCleanerPlus_vXXX.zip. This will load and install the plugin into Sigil, which you can then select and run using Plugins > Edit > CustomCleanerPlus

Description
This plugin cleaner is an edit plugin that can be used to clean-up both epubs and imported html docs. It also transforms html code to help ensure proper xhtml compliance to epub 2 format. This plugin only supports epub 2 ebooks(not epub 3).

For epubs, this plugin cleaner is best used after using an epub converter to remove any dross or non-compliant proprietary data still remaining in the epub html and stylesheet.

For those folks who prefer crafting their epubs from an html doc imported into Sigil as their start point, this plugin should also prove useful. You should use html documents with this plugin that are only derived from the following doctypes: Word doc and docx(html filtered only), ODF(OO and LO docs only), GoogleDoc(as html, zipped) and AbiWord.

To load an html doc into Sigil, first open Sigil and go to Edit > Tools > Preferences > General Settings > Mend XHTML Source Code On: and set this to Open and then save it(you only have to do this once). Now you can load the html file in the normal way using File > Open(ensure File Types is set to html).

Features

Automatic Tasks(applied to both epubs and imported html docs)
-- Thoroughly cleans out and reformats all html files
-- Removes or changes all unneeded or non-compliant proprietary data in the html
-- Trims the epub stylesheet(s) - removes any unneeded or redundant class properties from the css
-- Repairs illegal digit-start-char and spacing id values in html files only(added in v0.2.8)
-- Ensures that all ebook image formatting is epub 2 compliant
-- Removes all empty spans(ie spans that contain no styling or classes)
-- Removes all hard line breaks(blank lines) caused by the enter key
-- Removes all html tags that are empty or that contain just spaces
-- Removes all tabs

Cleanup Options(via dialog):
-- Convert all <i>, <b>, <em>, <u>, <s> and <strong> tags to span tag styling
-- Convert all ebook text and headings to default serif throughout
-- Reformat ebook images using percentage screen values to help normalize smaller image sizes across all ereaders.
-- Remove all internet link formatting
-- Remove all internal link formatting (will not remove Sigil-generated TOC link formatting in epubs)
-- Remove all bookmarks
-- Remove all <div> tags

Plugin Run
First load your epub or html doc into Sigil and then just run this plugin. For epubs also ensure, before you run this plugin, that your epub is fully formed and contains the appropriate ebook cover, html files, xml files, stylesheet(s), images etc. After running the plugin it would also perhaps be advisable to run several passes of Sigil's Tool > Delete Unused Stylesheet Classes or just use the cssRemoveUnusedSelectors plugin to mop up any empty or unused classes in your epub's stylesheet(s) after the clean up.

Caveats
Don't use SVG wrappers for ebook images in your epub with this plugin because it will cause problems. Unfortunately, due to a quirk with the Tidy module, these SVG problems can't be resolved. Also avoid using fake smallcaps in you doc headings as this can cause nested <font> tag problems. Best to add the fake smallcaps to your epub styling in Sigil after running this plugin. You will normally get best results by using only paragraph style formatting for all text, headers and spacing in your doc. Do not use tables or captions in your html doc with this plugin.

Changes
Spoiler:

v0.2.9
-- Fixed a problem with the version updater.
-- Fixed a formatting problem with the epub TOC file.
v0.2.8
-- Now automatically repairs illegal digit-start-char and spacing id values in html files only
v0.2.7
-- Removed default CSS formatting(unnecessary)
v0.2.6
-- Fixed a CSS link bug occurring in Word derived epubs only.
v0.2.5
-- Added MIT SW Licence
v0.2.4
-- fixed div/anchor bug
v0.2.3
-- fixed css display: none bug
-- fixed css semi-colon bug
-- fixed css curly brace spacing bug
-- fixed toc item spacing bug(Scrivener epubs only)
v0.2.2
-- Improved cleanup on exit
-- Now automatically fixes all standalone <img> tag displays in the html
v0.2.1
-- Adjusted base pixel screen width for % width calculation in the reformat image function.
v0.2.0
-- Now ensures proper removal of all page break declarations from the epub css.
v0.1.9
-- Fixed a problem with multi-line comments in the css. Thanks to wrCisco.
v0.1.8
-- Fixed an image reformatting problem. Thanks to roger64.
v0.1.7
-- Increased user dialog font size for better readability on OSX. Thanks to KevinH.
v0.1.6
-- Fixed an html css formatting issue for Word doc html input.
v0.1.5
-- Fixed an issue with the 'Save selection' chkbutton not properly saving current chkbutton selections in the user dialog window.
v0.1.4
-- Fixed cleanup issues on exit.
v0.1.3
-- Added a "Save selection" chkbox to allow saving current user dialog selections for future sessions. Requested by Thasaidon.
v0.1.2
-- Changed from using default font size to fixed font size(9pt) to try and help alleviate Arch Linux dialog window issues.
v0.1.1
-- Added checks to ensure epub 2.0 only documents are used with this plugin. My thanks to DiapDealer & Doitsu.
v0.1.0
-- Initial release
Attached Files
File Type: zip CustomCleanerPlus_v029.zip (971.6 KB, 0 views)

Last edited by slowsmile; Today at 12:01 AM.
slowsmile is offline   Reply With Quote
Old 07-04-2017, 07:04 AM   #2
slowsmile
Witchman
slowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of light
 
Posts: 211
Karma: 12036
Join Date: May 2013
Location: Philippines
Device: Android S5
I need some help with this plugin. Although I've put in all the necessary code for this plugin to also run on Mac and Linux, I have no means of testing this plugin on these op systems due to lack of hardware facilities. So could someone please quickly test this plugin on their Linux or Mac and let me know if it works without major problems on this thread? My grateful thanks in advance.

Last edited by slowsmile; 07-04-2017 at 07:22 AM.
slowsmile is offline   Reply With Quote
Old 07-04-2017, 08:34 AM   #3
PandathePanda
a toy panda
PandathePanda ought to be getting tired of karma fortunes by now.PandathePanda ought to be getting tired of karma fortunes by now.PandathePanda ought to be getting tired of karma fortunes by now.PandathePanda ought to be getting tired of karma fortunes by now.PandathePanda ought to be getting tired of karma fortunes by now.PandathePanda ought to be getting tired of karma fortunes by now.PandathePanda ought to be getting tired of karma fortunes by now.PandathePanda ought to be getting tired of karma fortunes by now.PandathePanda ought to be getting tired of karma fortunes by now.PandathePanda ought to be getting tired of karma fortunes by now.PandathePanda ought to be getting tired of karma fortunes by now.
 
PandathePanda's Avatar
 
Posts: 2,241
Karma: 17479226
Join Date: Mar 2014
Location: Onboard the Queen Anne's Revenge
Device: Various Android dvices
Had a quick test on Ubuntu, using sigil 0.9.8 and didn't get any errors except the known svg one
PandathePanda is offline   Reply With Quote
Old 07-04-2017, 08:39 AM   #4
slowsmile
Witchman
slowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of light
 
Posts: 211
Karma: 12036
Join Date: May 2013
Location: Philippines
Device: Android S5
@PandathePanda...Much thanks for that. So I guess the plugin works on Linux. Will amend the release notes now. Thanks again for helping out...
slowsmile is offline   Reply With Quote
Old 07-04-2017, 09:09 AM   #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: 17,029
Karma: 89654632
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Two things:

1) Cosmetic-only issues on Arch Linux with the tkinter gui: The "Clear All" button overlaps the "Select All" button and obscures part of the text. And the initial width of the widget does not allow all of the text for the options to be seen. Neither of these are deal-breakers, of course.

2) A little more serious ... many of the options result in destructive damage to the nav document of EPUB3s. You may want to do a quick check of the EPUB version and abort on EPUB3s if your plugin not prepared to support them at this time.

Code:
bk.epub_version()
Returns as a unicode string the epub version ("2.0" or "3.0") of the current epub as determined by the version attribute value on the OPF package tag (first available in Sigil v0.9.3).

You can also parse the value of bk.getpackagetag() for the "version" attribute if you want to check the epub version in versions of Sigil earlier than v0.9.3.
DiapDealer is offline   Reply With Quote
Advert
Old 07-04-2017, 09:38 AM   #6
slowsmile
Witchman
slowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of light
 
Posts: 211
Karma: 12036
Join Date: May 2013
Location: Philippines
Device: Android S5
@DiapDealer...Thanks for your response and solutions.

Regarding my plugin -- I thought that I had made it clear in the first paragraph of my Description in my release notes that this plugin only applied to standard epub or epub 2. But of course you're right -- it's best to initially use version detection early on using bk.epub_version() to raise an error if someone uses the plugin for epub 3.

Regarding the button and checkbox display problems, I'm simply using standard grids to arrange both these entities in the dialog which has worked fairly well on other plugins that I've released. The poster before you -- PandathePanda, using Ubuntu Linux -- said that there were no problems with my displays. I'm afraid that I'm clueless about the fine nuances and differences between Ubuntu Linux and Arch Linux so I really don't know how to remedy that one. I am soon hoping to move over to Qt5 for my future plugin windowing -- still learning. I really hope and pray that Qt5 has a better cross-platform capability than Tkinter.

I'm also thinking of putting Linux Mint on a partition on my laptop soon which might help. At least that will allow me to test my plugins on Linux. Well, sort of...

Last edited by slowsmile; 07-04-2017 at 09:40 AM.
slowsmile is offline   Reply With Quote
Old 07-04-2017, 09:54 AM   #7
Doitsu
Wizard
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: 3,888
Karma: 10764058
Join Date: Dec 2010
Device: Kindle PW2
@slowsmile: I experienced the same tkinter layout problems on my Arch Linux machine as DiapDealer.

As for bk.epub_version(), it's a relatively recent addition. You might want to add a fallback for older versions. For example:

Code:
    # get epub version number
    if bk.launcher_version() >= 20160102:
        epubversion = bk.epub_version()
    else:
        epubversion = BeautifulSoup(bk.get_opf(), 'lxml').find('package')['version']
Of course you could also simply state that your plugin requires Sigil 0.9.3 or higher.
Doitsu is offline   Reply With Quote
Old 07-04-2017, 10:26 AM   #8
slowsmile
Witchman
slowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of light
 
Posts: 211
Karma: 12036
Join Date: May 2013
Location: Philippines
Device: Android S5
@Doitsu...Thanks for all your advice and helpful examples. That's a great help. And I think I will change the Sigil version requirement to v9.3.

Last edited by slowsmile; 07-04-2017 at 10:49 AM.
slowsmile is offline   Reply With Quote
Old 07-04-2017, 10:51 AM   #9
slowsmile
Witchman
slowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of light
 
Posts: 211
Karma: 12036
Join Date: May 2013
Location: Philippines
Device: Android S5
I've changed and updated the plugin code and put checks into the plugin to ensure that only Epub 2.0 docs can be used.

Last edited by slowsmile; 07-05-2017 at 04:45 AM.
slowsmile is offline   Reply With Quote
Old 07-05-2017, 05:58 PM   #10
slowsmile
Witchman
slowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of light
 
Posts: 211
Karma: 12036
Join Date: May 2013
Location: Philippines
Device: Android S5
I've just added a change to the plugin(v0.1.2). In the dialog window, I've changed from using the default font size to using a fixed font size(9pt) for all displayed text. Hopefully this change might go some way towards helping to alleviate some of the current dialog layout issues with Arch Linux.

Last edited by slowsmile; 07-06-2017 at 02:48 AM.
slowsmile is offline   Reply With Quote
Old 07-07-2017, 06:46 AM   #11
Thasaidon
Hedge Wizard
Thasaidon ought to be getting tired of karma fortunes by now.Thasaidon ought to be getting tired of karma fortunes by now.Thasaidon ought to be getting tired of karma fortunes by now.Thasaidon ought to be getting tired of karma fortunes by now.Thasaidon ought to be getting tired of karma fortunes by now.Thasaidon ought to be getting tired of karma fortunes by now.Thasaidon ought to be getting tired of karma fortunes by now.Thasaidon ought to be getting tired of karma fortunes by now.Thasaidon ought to be getting tired of karma fortunes by now.Thasaidon ought to be getting tired of karma fortunes by now.Thasaidon ought to be getting tired of karma fortunes by now.
 
Thasaidon's Avatar
 
Posts: 174
Karma: 2174406
Join Date: May 2011
Location: UK/Philippines
Device: Kobo Touch, Nook Simple
Small Request

Nice plugin. I have used it today an a dozen or so books and it has been most useful.

If I can suggest one minor improvement, could you make it remember the settings from the last time you used the plugin.

Thasaidon is offline   Reply With Quote
Old 07-07-2017, 07:04 AM   #12
slowsmile
Witchman
slowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of light
 
Posts: 211
Karma: 12036
Join Date: May 2013
Location: Philippines
Device: Android S5
@Thasaidon...Sure, I'll do your suggested change which is quite reasonable. I'm doing other fixes and stuff at the moment but I'll let you know on this thread when I've done the change. Might take a day or two...

Were you using Windows, OSX or Linux when you used this plugin? I'm sorry to have to ask this, but I need to know whether the plugin works on OSX and all flavors of Linux. At the moment there is a problem with the plugin dialog window text in Arch Linux but this seems to be OK on Ubuntu and that's all the feedback I've had. My thanks in advance...

Last edited by slowsmile; 07-07-2017 at 07:45 PM.
slowsmile is offline   Reply With Quote
Old 07-07-2017, 08:29 PM   #13
Thasaidon
Hedge Wizard
Thasaidon ought to be getting tired of karma fortunes by now.Thasaidon ought to be getting tired of karma fortunes by now.Thasaidon ought to be getting tired of karma fortunes by now.Thasaidon ought to be getting tired of karma fortunes by now.Thasaidon ought to be getting tired of karma fortunes by now.Thasaidon ought to be getting tired of karma fortunes by now.Thasaidon ought to be getting tired of karma fortunes by now.Thasaidon ought to be getting tired of karma fortunes by now.Thasaidon ought to be getting tired of karma fortunes by now.Thasaidon ought to be getting tired of karma fortunes by now.Thasaidon ought to be getting tired of karma fortunes by now.
 
Thasaidon's Avatar
 
Posts: 174
Karma: 2174406
Join Date: May 2011
Location: UK/Philippines
Device: Kobo Touch, Nook Simple
Thank you very much

I am using a Windows 7 64 bit setup with the latest versions of Calibre and Sigil.

I will be using the plug in a lot so will let you know if I hit any problems but after a dozen books or so I haven't found any.

I look forward to the next release of the plugin but there is no rush, whenever you can find the time.

Thanks again.

Quote:
Originally Posted by slowsmile View Post
@Thasaidon...Sure, I'll do your suggested change which is quite reasonable. I'm doing other fixes and stuff at the moment but I'll let you know on this thread when I've done the change. Might take a day or two...

Were you using Windows, OSX or Linux when you used this plugin? I'm sorry to have to ask this, but I need to know whether the plugin works on OSX and all flavors of Linux. At the moment there is a problem with the plugin dialog window text in Arch Linux but this seems to be OK on Ubuntu and that's all the feedback I've had. My thanks in advance...
Thasaidon is offline   Reply With Quote
Old 07-07-2017, 08:38 PM   #14
slowsmile
Witchman
slowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of light
 
Posts: 211
Karma: 12036
Join Date: May 2013
Location: Philippines
Device: Android S5
@Thasaidon...Thanks for your response.
slowsmile is offline   Reply With Quote
Old 07-08-2017, 09:30 AM   #15
slowsmile
Witchman
slowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of lightslowsmile is a glorious beacon of light
 
Posts: 211
Karma: 12036
Join Date: May 2013
Location: Philippines
Device: Android S5
@Thasaidon...I've just updated this plugin(v0.1.3) to include a "Save selections" checkbox which, when ticked, will save your current dialog selections for all future sessions until you change it. I hope it's OK for you.

Last edited by slowsmile; 07-08-2017 at 09:46 AM.
slowsmile is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with my ScrambleEbook plugin and the Plugin Updater tool jackie_w Development 14 01-19-2017 10:49 PM
[FileType Plugin] YVES Bible Plugin ClashTheBunny Plugins 23 08-16-2016 06:53 AM
Plugin not customizable: Plugin: HTML Output does not need customization flyingfoxlee Conversion 2 02-24-2012 02:24 AM
[GUI Plugin] Plugin Updater **Deprecated** kiwidude Plugins 159 06-19-2011 12:27 PM
New Plugin Type Idea: Library Plugin cgranade Plugins 3 09-15-2010 12:11 PM


All times are GMT -4. The time now is 02:27 AM.


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