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 03-25-2018, 10:21 PM   #1
slowsmile
Witchman
slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.
 
Posts: 493
Karma: 787388
Join Date: May 2013
Location: Philippines
Device: Android S5
[Plugin] RemoveUnusedBookmarks - removes all unused bookmarks from epubs

Removes all unused bookmarks from epubs

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, Linux or OSX
Current Version: "0.1.7"

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 RemoveUnusedBookmarks_vXXX.zip. This will load and install the plugin into Sigil, which you can then select and run the plugin by selecting Plugins > Edit > RemoveUnusedBookmarls

Description
This plugin's main task is to remove all unused bookmarks(internal link destination ids) from the epub. The plugin also does the following tasks:

* Converts all 'name' attributes to 'id' attributes.

* Removes all unused bookmarks/ids from the xhtml files.

* Removes all anchor tags that contain no attributes.

* Ensures that all anchor start and end tags(with id only and no link) are always correctly positioned before the parent tags' text string.

Caveat
* This plugin will remove all destination bookmarks/ids that are not directly used by internal links in the xhtml, toc.ncx, guides or nav.xhtml(for epub 3). The only exception to this is if an id contains markers such as "toc", "cover", "text", "start", which will not be removed.

* This plugin can now process Epub 2 and Epub 3 files. Pagelists and nav maps are supported.

Plugin Run
Load your epub into Sigil and then just run the plugin.

At the end of the run, the plugin will now display a results message window showing number of files processed, total bookmarks found and total bookmarks removed.(v0.1.1)

Update: This plugin can now process epubs that contain svg images without giving svg errors in Epubcheck.(v0.1.3)

Update: Both Epub 2 and Epub 3 files can now be processed with this plugin.


Changes:

Spoiler:

v0.1.7
-- Fixed a bug whereby if the epub contained SVG wrappers then the SVG code would be corrupted by the plugin, causing epubcheck errors.
v0.1.6
-- Improved html output(layout).
v0.1.5
-- Fixed several bugs which, under certain conditions, would give epubcheck errors.
-- This plugin can now be use with epub 2 and epub 3 files. My thanks to @democrite.
v0.1.4
-- The href ids are now more widely gathered from the following files: xhtml files, toc.ncx, opf manifest and opf guides. These href ids are then compared to existing ids/bookmarks in the xhtml files. The xhtml ids are only removed if they don't exist in the href id list.
-- NCX pagelists and page-map files are now not supported with this plugin. If either are detected in the epub then there will be a warning with bailout.
v0.1.3
-- Fixed a problem causing svg formatting errors in Epubcheck. SVG images can now be used in epubs without problems when using this plugin.
v0.1.2
-- The plugin now removes the meta line if it contains the 'name="calibre:cover"' attribute in the cover file. Thanks to Becky.
-- The plugin will now not change any "name" attribute values or names in any meta tags. Thanks to DiapDealer.
v0.1.1
-- Added a terminal window to display relevant plugin processing information for the user. Thanks to roger64.
v0.1.0
-- Initial release
Attached Thumbnails
Click image for larger version

Name:	results_dialog.JPG
Views:	226
Size:	18.8 KB
ID:	163069  
Attached Files
File Type: zip RemoveUnusedBookmarks_v017.zip (12.0 KB, 32 views)

Last edited by slowsmile; 10-30-2019 at 08:23 AM.
slowsmile is offline   Reply With Quote
Old 03-26-2018, 12:42 AM   #2
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,414
Karma: 2457001
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
Thank you for this useful plugin.

I would appreciate to read in the terminal window a comment of sort: "processed x files, found y bookmarks". Now it processes silentlly and I do not know if it really did the job.

Last edited by roger64; 03-26-2018 at 12:43 AM. Reason: typo
roger64 is offline   Reply With Quote
Advert
Old 03-26-2018, 12:59 AM   #3
slowsmile
Witchman
slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.
 
Posts: 493
Karma: 787388
Join Date: May 2013
Location: Philippines
Device: Android S5
@roger64...I'll try and add that terminal results window as a final info display when I have some time - I'm a bit busy at the moment.

Last edited by slowsmile; 03-26-2018 at 01:30 AM.
slowsmile is offline   Reply With Quote
Old 03-26-2018, 03:09 AM   #4
slowsmile
Witchman
slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.
 
Posts: 493
Karma: 787388
Join Date: May 2013
Location: Philippines
Device: Android S5
Update: The plugin will now display a terminal message window at the end of processing to show relevant processing information to the user.(v0.1.1)

Last edited by slowsmile; 03-26-2018 at 03:42 AM.
slowsmile is offline   Reply With Quote
Old 03-26-2018, 05:10 AM   #5
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,414
Karma: 2457001
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
Thank you
roger64 is offline   Reply With Quote
Advert
Old 03-26-2018, 10:15 AM   #6
BeckyEbook
Addict
BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.
 
BeckyEbook's Avatar
 
Posts: 226
Karma: 783002
Join Date: Jan 2017
Location: Poland
Device: Kindle (Key3, PW2, PW3), Nook (ST, GLP), Kobo Touch, Tolino Vision 2
@slowsmile: Think about it:

Code:
<meta name="description" content="Story awarded (first award)."/>
<meta name="keywords" content="award, story, john, doe, horror"/>
<meta name="author" content="John Doe"/>
<meta name="generator" content="BeckyPad 1.07"/>
And by the way about calibre:cover markers:
Code:
<meta name="calibre:cover" content="true"/>
Just skip the meta while checking.

Last edited by BeckyEbook; 03-26-2018 at 10:22 AM.
BeckyEbook is offline   Reply With Quote
Old 03-26-2018, 01:21 PM   #7
slowsmile
Witchman
slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.
 
Posts: 493
Karma: 787388
Join Date: May 2013
Location: Philippines
Device: Android S5
@Becky...It's now 12:10 am in the Philippines where I live and I'm going to bed now. I'll try and put in a fix for the "calibre:cover" IDErrorCheck problem tomorrow morning.

I would also appreciate it you would keep problems concerning the IDErrorCheck plugin on the correct forum thread. This thread is primarily for RemoveUnusedBookmarks plugin problems.
slowsmile is offline   Reply With Quote
Old 03-26-2018, 01:49 PM   #8
BeckyEbook
Addict
BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.
 
BeckyEbook's Avatar
 
Posts: 226
Karma: 783002
Join Date: Jan 2017
Location: Poland
Device: Kindle (Key3, PW2, PW3), Nook (ST, GLP), Kobo Touch, Tolino Vision 2
This thread IS correct.
Plugin RemoveUnusedBookmarks destroys meta tags.

IDErrorCheck too.

CustomCleanerPlus "only" remove them.

Last edited by BeckyEbook; 03-26-2018 at 01:54 PM.
BeckyEbook is offline   Reply With Quote
Old 03-26-2018, 02:09 PM   #9
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: 21,336
Karma: 116833268
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
I'm unclear as to what you're referring to as "bookmarks" and what is being used to determine that they're "unused."

From what I can see, this plugin modifies id attributes and anchor tags. Am I missing something?
DiapDealer is offline   Reply With Quote
Old 03-26-2018, 06:49 PM   #10
slowsmile
Witchman
slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.
 
Posts: 493
Karma: 787388
Join Date: May 2013
Location: Philippines
Device: Android S5
@DiapDealer...By bookmarks we mean ids.

What Becky is referring to is the the odd Calibre id that is inserted in Becky's cover.xhtml meta tag in her scrambled.epub document. The layout of the cover.xhtml file looks like this:

Spoiler:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta content="true" name="calibre:cover"/>
<title>Scrambled</title>
<style type="text/css">
@page {padding: 0pt; margin:0pt}
body { text-align: center; padding:0pt; margin: 0pt; }
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>

<body>


Becky is insistent that I should fix the above issue, which is actually caused by the Calibre conversion of her original doc to epub. This problem is caused by Calibre's non-standard use of meta ids in other words. I really don't know why that "calibre:cover" id is there in the meta tags of the cover file. It's obviously an irregular id that has been put there by Kovid Goyal for reasons that I am unable to fathom.

I can certainly put in a fix for this problem(by simply removing the offending meta line in the cover file) but it does irk me that such a non-standard and obviously fudged id is being generated by Calibre in all its conversions to epub which cause problems when my plugins are being used.

Last edited by slowsmile; 03-26-2018 at 10:02 PM.
slowsmile is offline   Reply With Quote
Old 03-26-2018, 07:42 PM   #11
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: 21,336
Karma: 116833268
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by slowsmile View Post
@DiapDealer...By bookmarks we mean ids.
OK, thanks. I'd just never heard them referred to as bookmarks before.
DiapDealer is offline   Reply With Quote
Old 03-26-2018, 07:49 PM   #12
BeckyEbook
Addict
BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.
 
BeckyEbook's Avatar
 
Posts: 226
Karma: 783002
Join Date: Jan 2017
Location: Poland
Device: Kindle (Key3, PW2, PW3), Nook (ST, GLP), Kobo Touch, Tolino Vision 2
But I do not insist.
I just notice that the use of some plugins damages my metadata in files. The workaround would be to leave name unchanged in the meta tags.

The default cover template in calibre actually contains
Code:
<meta content="true" name="calibre:cover"/>
It would be better to remove the whole line than leave such a version (after using the plugin):
Code:
<meta content="true"/>
BeckyEbook is offline   Reply With Quote
Old 03-26-2018, 08:31 PM   #13
BetterRed
null operator
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 14,953
Karma: 12775412
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by slowsmile View Post
I really don't know why that "calibre:cover" id is there in the meta tags of the cover file. It's obviously an irregular id that has been put there by Kovid Goyal for reasons that I am unable to fathom.
Rather than making snide comments here, why don't you ask Kovid Goyal directly why the "calibre:cover" id exists, he's only a PM away.

BR
BetterRed is offline   Reply With Quote
Old 03-26-2018, 09:30 PM   #14
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: 21,336
Karma: 116833268
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Becky's got a point. Your plugin really should be excluding meta tags when it's doing it's processing. Those tags aren't relevant to your plugin's stated workflow after all.

Calibre/Kovid's reasons for what he does are immaterial to this issue. "name" is a valid attribute for meta tags, and "calibre:cover" violates no xhtml value character rules. Your plugin should not mangle them (or any existing meta tag)--especially since they're not in your plugin's bailiwick to begin with.

Your code is changing every "name" attribute it finds (in any tag) to an "id" attribute. That's just a bad idea.

Change:
Code:
#ensure all bookmarks have only 'id' attributes
for tag in soup.find_all(True):
    if tag.has_attr('name'):
        idref = tag['name']
        del tag['name']
        tag['id'] = idref
to:
Code:
#ensure all bookmarks have only 'id' attributes
for tag in soup.find_all(True):
    if tag.has_attr('name') and tag.name != "meta":
        idref = tag['name']
        del tag['name']
        tag['id'] = idref
and be done.

There's no reason for this plugin to be changing any meta tags.

Last edited by DiapDealer; 03-26-2018 at 10:04 PM.
DiapDealer is offline   Reply With Quote
Old 03-26-2018, 10:08 PM   #15
slowsmile
Witchman
slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.
 
Posts: 493
Karma: 787388
Join Date: May 2013
Location: Philippines
Device: Android S5
@DiapDealer...I've already fixed the 'calibre:cover' issue by removing the line in the cover file. But I take your point that meta tags with ids should not be checked or changed. Will work on a fix for that now. These fixes will be included in both IDErrorCheck and RemoveUnusedBookmarks plugins. And thanks for the heads up info on meta ids, I didn't know that.

Last edited by slowsmile; 03-26-2018 at 10:12 PM.
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
Removing plugin in Calibre removes it from all instances of Calibre oblox Calibre 9 09-09-2016 06:39 AM
iPad Possibility to sync bookmarks through side loaded ePubs (Any iOS software?) andsoitgoes Apple Devices 12 04-13-2012 08:38 PM
Modify bookmarks in epubs silentguy Development 3 08-03-2011 06:37 PM
Sideloaded ePubs, chapters and bookmarks Steven Lyle Jordan Nook Color & Nook Tablet 10 02-05-2011 07:35 PM
Problem (bug) with bookmarks in PDF plugin (2.0 RC2) luite iRex 1 07-12-2010 03:36 AM


All times are GMT -4. The time now is 01:17 PM.


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