![]() |
EpubCheck plugin for Sigil
1 Attachment(s)
[Plugin] EpubCheck - Simple epubcheck wrapper
Updated: November 15, 2021 Current Version: "0.4.6.2" This plugin is a very simple EPUBCheck v4.2.6 wrapper. Note that since the EPUBCheck Java app is executed in the background, you'll have to wait a couple of seconds before the messages are being displayed. Disclaimer: Even though it's unlikely that the plugin will somehow corrupt the epub that you're working on or crash Sigil, you may want to save your ePub in Sigil before running this plugin. System requirements Before installing the plugin, please make sure that the following system requirements are met: 1. Python 2.7.x (or Python 3.4)* 2. Java 1.8 or higher * Not required for Sigil 0.9.0 and higher, which comes with Python 3. To find out whether these programs are installed, enter the following commands in a terminal/command prompt window: python -V (should display Python 2.7.x/3.x) java -version (should display java version "1.8.0_xx" or a higher version number) Installation 1. Select Manage Plugins from the Plugins menu, then select Use Bundled Python, if it isn't already selected. If you haven't updated to Sigil 0.9.0 (or higher), click one of the Auto buttons to detect the Python interpreter path or Set to manually select it. 2. Click Add Plugin and select epubcheck_v0.4.6.2.zip. This will install the epubcheck plugin, which you can select via Plugins > Validation > epubcheck. Settings You can control several EpubCheck plugin settings via the EpubCheck.json file, which'll be generated after the first run of the plugin. (To enable a setting change false to true.) Code:
{The following language codes can be used: Code:
"en", "de", "es", "fr", "it", "ja", "nl", "pt-BR", "ko-KR", "zh_TW", "da"github if enabled, the plugin will check the W3C Github site for EPUBCheck updates. (This setting is enabled by default.) clipboard_copy if enabled, the plugin will automatically copy validation results to the system clipboard. (This setting is disabled by default and might not work with some Linux/macOS versions.) update_check if enabled, the plugin will check MR for plugin updates. (This setting is enabled by default.) check_interval the number of days between update checks. (The default value is 7; i.e., the plugin will check for updates once a week.) usage if enabled, the plugin will also display best practice recommendations. (This setting is disabled by default.) is32bit If you're getting a StackOverflow error message, change this value to true. Troubleshooting tips for Windows users Java isn't found If your getting a FileNotFound Python error message or an error message after entering java -version, Java is most likely not installed and/or the path to the Java binaries wasn't added to the Windows PATH environment variable. If you're unsure whether Java is installed on your machine download and install the latest Java version. (You might have to reboot your machine after the installation.) If you're pretty sure that Java is installed on your machine open the Windows Explorer and look for the following folders: Code:
C:\Program Files\Java\Code:
C:\Program Files\Java\jre1.8.0_25\binYou should now get a version number, when you enter java -version in a command prompt window. Note: If you install Java for the first time make sure to disable the Java browser plugin(s). Python isn't detected when you click the Auto button If no Python path is detected when you click Auto in the Manage Plugins dialog box, install Python. (However, it'd be much easier, if you simply checked the Use Bundled Python option, if it isn't greyed out.) Troubleshooting tips for macOS users Since the update check feature might not work with certain macOS/Sigil versions, you might have to manually download the latest EPUBCheck files from the W3C website. (Unzip epubcheck.jar and the lib folder to the EpubCheck plugin folder.) License: GNU General Public License v3 (GPL-3) |
Very nice!
|
Thanks Doitsu!
This is a very nice idea and AFAIK after 3 quick tries, its work well. Cheers. |
Hi,
Yes, very nicely done. And the perfect thing for a plugin. Is there a moderator here who can add this plugin thread to the sticky list of plugins? Thanks! KevinH |
Stuck
|
Thanks for the plugin. It's the first I've tried, and when I run it I get the following error:
Error: Registry key 'Software\JavaSoft\Java Runtime Environment'\CurrentVersion' has value '1.8', but '1.7' is required. Error: could not find java.dll Error: Could not find Java SE Runtime Environment. Java and SE Runtime are installed and in the system path. Any idea why I'm getting this error. Thanks for your help. |
Quote:
Unless you have other more important Java programs installed that require a specific Java version, I'd recommend downloading and installing the latest 32bit and 64bit Java versions from Oracle. (The installer will automatically remove older versions.) Also don't forget to add/update the PATH environment variable as described in my first post. (If you enter java -version in a command prompt window and don't get a version number, the plugin will not work.) If you still can't get it to work, I'd recommend downloading epagina's user-friendly epubcheck version, which should work with Java 1.6. or higher. |
This was something Kevin and I talked about but never had the time to do. It looks like you're going to force us to make a new plugin type specifically for validators sooner rather than later.
|
Hi,
Actually the output plugin works well for this as it changes nothing at all in the current ebook files inside Sigil as the only access is via a book copy but does make the entire ebook (less mimetype) file available. Now if you wanted to do something special with the epubcheck output or wanted to make it easy to highlight text needing work in files or something along those lines, then a separate plugin type for validators with expanded capability would truly be needed. Basically, the same approach used by Doitsu can be used to invoke kindlegen or any other separate tool. So if Doitsu or any other plugin author wants to build a Kindlegen plugin, say maybe with a search to find the kindlegen executable on the users system or a filedialog to allow users to select it and saved preferences for settings and options for kindlegen that would be a wonderful thing!!! ..... Hint Hint ;) KevinH |
Quote:
|
Thanks for the help with my java problem. It is fixed. When I looked I found some old entries in the Program Data folder and the registry. I also uninstalled 1.7 but left 1.8...
Neat plugin! |
@Doitsu,
The next release of Sigil will include a "validation" plugin type. If you use it then you can set the validation results in the plugin and they'll be loaded into the validation pane in the main window. Just like what happens when you use FlightCrew. This means the results won't disappear when the plugin runner dialog is closed and you can click on the entry to go directly to the associated error line. Here is a quick example of how you'd use it in a plugin: Code:
def run(bk): |
Quote:
|
epubcheck
Thanks for the guidance.
I got everything installed and apparently running OK. The tool doesn't like any header. What is a "XML NMTOKEN"? Code:
Code:
<head> |
Quote:
Code:
<meta content="2014/11/29" name="dcterms.date of publication" />You may want to define these entries in Sigil's Metadata Editor instead. |
New beta version uploaded
I've uploaded a new epubcheck version with validation pane support for Sigil 0.8.2. (It's attached to the first message in this thread.)
The new version emulates the behavior of FlightCrew. I.e., it'll write error messages to the Validation Results window and you can now click on an error message to display the line it refers to. Like the previous version it'll also write the epubcheck output to the Plugin Runner window, which you'll need to close by clicking OK to access the Validation Results window. This update was only tested with the 32bit/64bit Windows and Linux versions of Sigil, however, it should also work with the OSX version. Note: Before you can install the new version (epubcheck_v0.2.zip), you'll need to uninstall the currently installed version via Plugins > Manage Plugins > epubcheck > Remove Plugin. If you get the following message in the Plugin Runner window after running the plugin: Code:
Status: failed |
Doitsu;
Installed epubcheck_v0.2.zip. epubcheck seems to cause a problem. Before run Code:
<meta content="2014/11/30" name="dcterms.date.of publication" />Code:
<meta content="2014/11/30" name="dcterms.date of publication" />Code:
<meta content="2014/11/30" name="dcterms.date.of publication" />Code:
<meta content="2014/11/30" name="dcterms.date of publication" /> |
Hi,
As Doitsu said, you should remove all of the metadata from that html page and convert it to proper dc metadata at the book level using Sigil's metadata editor. The metadata you have is not correct for dcterms and has spaces in the name "field" which are not allowed. So either remove it completely or change it to Code:
name="dcterms.dateOfPublication"Or better yet, convert it to be proper dc or dcterms metadata. KevinH |
Quote:
I've just tested it with Drift from Two Shores.epub, which you uploaded yesterday in DiapDealer's thread and didn't see any changed lines nor was an asterisk being displayed after the file name in the title bar. If you're still convinced that the plugin changes the content of epubs, please attach one that will be changed after running the epubcheck plugin. |
My problem may not be with epubcheck. It has worked corectly once or twice.
I have the Validations Results panel locked at the bottom of the sigil display. When working correctly, the results appear in the locked Validation Results panel. When things go wrong the Validation Results appears as a floating panel. |
Quote:
If you use a floating Validation Results window, it might overlap with the Plugin Runner window and hide it. For this reason, you may want to dock the Validation Results window before running the epubcheck plugin. (Future Sigil versions won't have this issue.) If you find the updated version of the epubcheck plugin difficult to use, you can always use the online version, the pagina drag & drop version or the original epubcheck version (without validation pane support). |
I have the same issue that pete6055 described in #6, i. e.
"Error: Registry key 'Software\JavaSoft\Java Runtime Environment'\CurrentVersion' has value '1.8', but '1.7' is required. Error: could not find java.dll Error: Could not find Java SE Runtime Environment." And, likewise: "Java and SE Runtime are installed and in the system path" in my case. He managed to solve this problem, but I didn't really understand, how (and I woud not like messing my registry). Could you, please, give a step-by-step guidance for dummies? The interesting is that, some time ago, the plugin worked without problems. Thans in advance! |
Quote:
I'd recommend uninstalling both 32bit and 64bit versions from your machine and reinstalling the latest 32bit and 64bit versions from Oracle. (You'll also need to add the Java path to the PATH environment variable.) (Make sure that there are no Java leftovers in the Windows program folders (C:\Program Files\ or C:\Programme) after uninstalling Java and that there are no Java path related registry entries in the Windows registry, before installing the latest versions.) |
[QUOTE=Leonatus;2992353]I have the same issue that pete6055 described in #6, i. e.
"Error: Registry key 'Software\JavaSoft\Java Runtime Environment'\CurrentVersion' has value '1.8', but '1.7' is required. Error: could not find java.dll Error: Could not find Java SE Runtime Environment." And, likewise: "Java and SE Runtime are installed and in the system path" in my case. He managed to solve this problem, but I didn't really understand, how (and I woud not like messing my registry). Could you, please, give a step-by-step guidance for dummies? The interesting is that, some time ago, the plugin worked without problems. /QUOTE] I've also been fighting this problem - I'm using the "legacy" verson of Sigil on a 32 Bit XP machine. After quite a bit of fiddling it became apparent that the problem was with Java. I had 1.7 and 1.8 installed but with 1.7 deactivated in the Java control panel. I've solved the problem by completely uninstalling the 1.7 version - using the system/control panel (not the Java control panel). Now Sigil's plugins work. HTH BobC |
Thank you, BobC! It might well be as you say. I bought me a new computer, and there is no issue.
|
Hi, I have just discovered the plugin possibilities for sigil and now I am testing the epubcheck plugin.
I have installed python, I have installed java. And it works for example with the sanitychecker plugin. But I run into the following problem wit the epubcheck plugin: I am in Calibre, I use the "open with" plugin to open an epub in sigil and then I run the epubcheck plugin within sigil. I then get this error message within the epubcheck plugin window: Status: failed Traceback (most recent call last): File "C:\Program Files\Sigil\plugin_launchers\\python\launcher.py", line 135, in launch self.exitcode = target_script.run(container) File "C:\Users\Dirk\AppData\Local\sigil-ebook\sigil\plugins\epubcheck\plugin.py", line 41, in run result = jarWrapper(*args) File "C:\Users\Dirk\AppData\Local\sigil-ebook\sigil\plugins\epubcheck\plugin.py", line 15, in jarWrapper process = Popen(list(args), stdout=PIPE, stderr=PIPE) File "C:\Python27\lib\subprocess.py", line 710, in __init__ errread, errwrite) File "C:\Python27\lib\subprocess.py", line 958, in _execute_child startupinfo) WindowsError: [Error 2] The system cannot find the file specified Error: [Error 2] The system cannot find the file specified I am NOT sure what it means. But, if I go into the calibre library folder, and so AVOID the "open with" plugin, and then open the same epub file there with sigil and then run the epubcheck plugin, it executes normally. Any pointers to make this sigil plugin work while using the calibre "open with" plugin with sigil would be much appreciated, as it saves me lots of time using the "open with" plugin. |
The latest version of calibre does include a native Open With capability, right-click on the format in calibre.
Might help. |
Cool. That works. Marvelous. Thank you very much. That made my day.
|
IMHO, running Sigil only to run epubcheck is a bit of overkill. It'd be easier to simply add pagina EPUB-Checker as a Calibre Open With app. (This app is also based on epubcheck 3.0.1.)
|
I'm guessing the original issue has something to do with a python plugin subprocessing a c++ program that was subprocessing a python plugin that was subprocessing a java program. ;)
Actually, I see in the Open With plugin code that there's a special handler for Sigil on Windows that involves the PATH being deleted from the retrieved os.environ dictionary before launching the Sigil subprocess. I'm sure something necessitated that bit of trickeration, but unfortunately, it also means that any Sigil plugin that relies on the ability to launch an external program without the full path to the exe is doomed to failure whenever Sigil is launched via the Open With calibre plugin on Windows. The "Open With" plugin also first blanks the LD_LIBRARY_PATH (for all launched subprocesses) on Linux, so any Sigil plugins that rely on using/diddling the LD_LIBRARY_PATH will be doomed to similar failures when Sigil is launched via the OW plugin on Linux. Good to know that the new native "Open With" calibre feature eliminates the problem. :thumbsup: |
I've attached a new version that runs epubcheck 4.0.1 and is compatible with Python 3.4.x and Python 2.7.x.
The new version does not add any new functionality for checking ePub2 files and requires the Java 1.6 runtime (Java 1.7 recommended). |
Hi, Doitsu! I've downloaded the new version but receive this message:
Code:
Running ePubCheck ... please waitWindows 10, 32 bit engine. |
FWIW, errors like this typically happens when latin1 or cp1252 chars are passed to python routines that are expecting utf-8 encodings. In this case, an error is being detected or generated by the plugin and it is the error message itself that is causing the issue as its contents are not utf-8.
You could run epubcheck via the command line and see what gets sent to std error to see what might be going on. To prevent this issue in future versions of the launcher I will tell it to 'replace' on error. |
Thanks, KevinH! Unfortunately, I don't know how to run epubcheck via command line under Windows 10.
But I'll send the file where this occurs and further information to Doitsu. He will have a look at it. |
Sigil 0.9 64 bit Windows 10
"Use bundled python" What's going wrong? I got this working once! Thanks Status: failed Traceback (most recent call last): File "C:\Program Files\Sigil\plugin_launchers\python\launcher.py", line 134, in launch target_script = __import__(script_module) File "C:\Users\lp\AppData\Local\sigil-ebook\sigil\plugins\ePubTidyTool\plugin.py", line 27, in <module> from ManualWordChecker import cManualWordCheck File "C:\Users\lp\AppData\Local\sigil-ebook\sigil\plugins\ePubTidyTool\ManualWordChecker .py", line 9, in <module> from bs4 import BeautifulSoup ImportError: No module named 'bs4' Error: No module named 'bs4' |
Because you haven't installed BeautifulSoup4, I would assume.
|
Sigil's bundled Python has no bs4 module. It has a modified version of BeautifulSoup called sigil_bs4 that's available to all plugins.
Developers who want plugins which have a bs4 dependency to work with Sigil's bundled python AND an external python installation will probably want to do something like: Code:
try:Just using: Code:
from sigil_bs4 import BeautifulSoupEven if you have no plans to support external python interpreters with your plugin, it will still probably be a good idea to incorporate the try/except technique with (sigil_)bs4 for future-proofing. bs4 is currently the only "non-stock" python module that Sigil uses. If the constraints that force us to use it ever go away, we'd love to do away with it and replace it with the stock version. This technique will ensure your plugin's continued functionality in the event that happens. Quote:
|
Yet another error message. Windows 10 x64. The error only occurs when I launch Sigil using Calibre's Open With plugin. Otherwise, I get the expected No problems found! message in Sigil's message box.
Code:
Status: failed |
FWIW: I do not think opening an app like Sigil with its builtin python 3 in a python 2.7 program like Calibre would be generally a good idea.
KevinH |
Quote:
|
| All times are GMT -4. The time now is 06:06 PM. |
Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.