07-04-2017, 07:36 AM | #1 |
Witchman
Posts: 628
Karma: 788808
Join Date: May 2013
Location: Philippines
Device: Android S5
|
[Plugin] CustomCleanerPlus
An epub-specific custom cleaning utility. 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.6.1" Installation * Select Manage Plugins from the Plugins menu. In the dialog box, select either the Bundled Python or 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 epub-specific plugin cleaner is an edit plugin that can be used to clean-up epubs. It also transforms html code in the epub to help ensure proper xhtml compliance with epub format. This plugin no longer supports HTML clean-up but can now be used for cleaning up Epub 2 and Epub 3 files(Added in v0.5.0). A characteristic feature of this plugin cleaner is that it is epub-specific and will not destroy, change or remove user styling. This plugin cleaner is best used after using an epub converter in order to remove any dross or non-compliant proprietary data still remaining in the epub html or stylesheet. Note: Please also take note that this plugin no longer supports any kind of HTML file input or HTML file clean-up. Only Epub cleanup is supported for this plugin now. Features Automatic Cleanup Tasks -- Thoroughly cleans out and reformats all html file sections. -- 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 at least epub 2 compliant -- Now removes all unused bookmarks from the epubs.(added in v0.3.2) -- Removes all empty spans(ie spans that contain no styling or classes) -- Removes all tabs -- Repair the image names by replacing all illegal spaces with underscores. Added in v0.5.0. -- Adds the relevant chapter/section heading string to the <title></title> tags. Added in v0.5.0. -- Adds a valid 'alt' attribute value to all <img> tags, which is derived from the image filename. Added in v0.5.0. User Options 1: -- Added in v0.5.3 -- Convert all <i>, <b>, <em>, <u>, <s> and <strong> tags to span tag styling -- Remove all unnecessary ad hoc black text color declarations from the css and from the html. Added in v0.5.0. -- Remove all unnecessary ad hoc white background color declarations from the css and from the html. Added in v0.5.0. -- Reformat ebook images to using percentage screen values to help normalize smaller image sizes across all ereaders. -- Remove any unused images stored in Sigil's 'Images' directory. Added in v0.5.0. -- Remove all hard breaks(<br> tags) caused by the enter key(added in v0.3.5) -- Remove all non-breaking spaces from the html(ie , *). Added in v0.5.0. -- Remove all hyphen class properties from the CSS(e.g. hyphens, adobe-hyphenate, -moz-hyphens, -webkit-hyphens etc).Added in v0.5.0. -- Remove all font family declarations in the CSS. Added in v0.5.0. -- Remove empty paragraphs that contain no text. Added in v0.5.0. User Options 2: -- Added in v0.5.3 -- Remove all internal ids and associated link formatting while preserving the text. Added in v0.5.0. Now also removes id fragments from both internal links and from the OPF links in the guide section as well. Added in v0.5.3 -- Replaced all <div> tags -- Remove all internet link formatting -- Remove all internal link formatting -- Remove the line-height property from CSS. Added in v0.5.3 -- Remove all horizontal rule html tags from the html. Added in v0.5.0 -- Remove all ids/bookmarks -- Replace <div> tags with <p> tagsw. Added in v0.5.0. -- Remove page links only. Added in v0.5.0. -- Remove empty spans i.e. remove spans that contain no formatting. Added in v0.5.3 Plugin Run Before running this plugin for the first time -- please make absolutely sure that you have Visual Studio 2010 (VC++ 10.0) SP1 already installed on your computer system. If it isn't installed then you should install it. Doing this will ensure that there are no tidy.dll access errors when you run this plugin. First load your epub 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 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:
Last edited by slowsmile; 12-18-2023 at 01:13 AM. |
07-04-2017, 08:04 AM | #2 |
Witchman
Posts: 628
Karma: 788808
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 08:22 AM. |
Advert | |
|
07-04-2017, 09:34 AM | #3 |
a toy panda
Posts: 2,567
Karma: 26020474
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
|
07-04-2017, 09:39 AM | #4 |
Witchman
Posts: 628
Karma: 788808
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...
|
07-04-2017, 10:09 AM | #5 |
Grand Sorcerer
Posts: 28,040
Karma: 199464182
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() 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. |
Advert | |
|
07-04-2017, 10:38 AM | #6 |
Witchman
Posts: 628
Karma: 788808
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 10:40 AM. |
07-04-2017, 10:54 AM | #7 |
Grand Sorcerer
Posts: 5,640
Karma: 23191067
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'] |
07-04-2017, 11:26 AM | #8 |
Witchman
Posts: 628
Karma: 788808
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 11:49 AM. |
07-04-2017, 11:51 AM | #9 |
Witchman
Posts: 628
Karma: 788808
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 05:45 AM. |
07-05-2017, 06:58 PM | #10 |
Witchman
Posts: 628
Karma: 788808
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 03:48 AM. |
07-07-2017, 07:46 AM | #11 |
Hedge Wizard
Posts: 802
Karma: 19999999
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. |
07-07-2017, 08:04 AM | #12 |
Witchman
Posts: 628
Karma: 788808
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 08:45 PM. |
07-07-2017, 09:29 PM | #13 | |
Hedge Wizard
Posts: 802
Karma: 19999999
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:
|
|
07-07-2017, 09:38 PM | #14 |
Witchman
Posts: 628
Karma: 788808
Join Date: May 2013
Location: Philippines
Device: Android S5
|
@Thasaidon...Thanks for your response.
|
07-08-2017, 10:30 AM | #15 |
Witchman
Posts: 628
Karma: 788808
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 10:46 AM. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[FileType Plugin] YVES Bible Plugin | ClashTheBunny | Plugins | 27 | 01-16-2023 02:25 AM |
Problem with my ScrambleEbook plugin and the Plugin Updater tool | jackie_w | Development | 14 | 01-19-2017 11:49 PM |
Plugin not customizable: Plugin: HTML Output does not need customization | flyingfoxlee | Conversion | 2 | 02-24-2012 03:24 AM |
[GUI Plugin] Plugin Updater **Deprecated** | kiwidude | Plugins | 159 | 06-19-2011 01:27 PM |
New Plugin Type Idea: Library Plugin | cgranade | Plugins | 3 | 09-15-2010 01:11 PM |