Mobileread
[Plugin] RemoveUnusedBookmarks - removes all unused bookmarks from epubs
#1  slowsmile 03-25-2018, 10:21 PM
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 Warning below







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
results_dialog.JPG 
[zip] RemoveUnusedBookmarks_v017.zip (12.0 KB, 38 views)
Reply 

#2  roger64 03-26-2018, 12:42 AM
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.
Reply 

#3  slowsmile 03-26-2018, 12:59 AM
@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.
Reply 

#4  slowsmile 03-26-2018, 03:09 AM
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)
Reply 

#5  roger64 03-26-2018, 05:10 AM
Thank you
Reply 

#6  BeckyEbook 03-26-2018, 10:15 AM
@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.
Reply 

#7  slowsmile 03-26-2018, 01:21 PM
@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.
Reply 

#8  BeckyEbook 03-26-2018, 01:49 PM
This thread IS correct.
Plugin RemoveUnusedBookmarks destroys meta tags.

IDErrorCheck too.

CustomCleanerPlus "only" remove them.
Reply 

#9  DiapDealer 03-26-2018, 02:09 PM
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?
Reply 

#10  slowsmile 03-26-2018, 06:49 PM
@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 Warning below






<?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.
Reply 

  Next »  Last »  (1/5)
Today's Posts | Search this Thread | Login | Register