Try   HackMD

電子書製作工具分享-EPub Checker

1.功能

EPub Checker是一套用來檢查EPub是否合乎標準規範的工具。透過檢查EPub規範,可以提升製作出來的EPub品質(註:應該說降低劣質的風險比較貼切)。這裡將會依照使用的方式,將其區分為指令工具以及圖形化工具,如果比較排斥使用 命令提示字元(cmd) 的人,建議可以直接跳到3.圖形化工具 閱讀。

  • 指令工具(彈性大、較輕量、便於自動化)
  • 圖形化工具(操作簡單、快速、且介面友善)

2.指令工具

2.1 安裝JAVA

  • 下載執行環境所需要的JDK
  • 打開命令提示字元(cmd),設定電腦環境變數。
C:\Users\USER> set JAVA_HOME=D:\openjdk-11.0.2_windows-x64_bin\jdk-11.0.2 C:\Users\USER> set PATH=D:\openjdk-11.0.2_windows-x64_bin\jdk-11.0.2\bin
  • 確認是否安裝成功。
C:\Users\USER> java -version openjdk version "11.0.2" 2019-01-15 OpenJDK Runtime Environment 18.9 (build 11.0.2+9) OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
符合jdk 1.6即可執行,不過官方建議使用jdk 1.7以上,個人測試則是以jdk 11(版本11.0.2)進行。

2.2 下載EPub Checker

  • 前往官網下載epubcheck-4.2.4.zip指令工具,並將其解壓縮。
  • 在命令提示字元(cmd)確認是否可以正常執行。
C:\Users\USER> cd C:\Users\USER\Downloads\epubcheck-4.2.4\epubcheck-4.2.4 C:\Users\USER> java -jar epubcheck.jar --version EPUB檢查器 4.2.4版 引數中未指定檔案。結束驗證。 EPUB檢查完成

2.3 如何使用EPub Checker

在執行java程式時,一般會以java -jar 要執行的*.jar檔的方式執行副檔名為jar的java程式。其中,後綴支援一些程式所提供的功能參數,範例是epub checker所提供的--help功能參數。

C:\Users\USER> java -jar epubcheck.jar --help EPUB檢查器 4.2.4版 當使用本工具時,第一個變數需是要檢查的檔案名稱(包含路徑)。 要指定驗證Profile(以檢查特定的EPUB Profile或者延伸規格),請使用 -profile 選項如下: 驗證Profile支援如下: --profile default = 以預設profile驗證 --profile dict = 以EPUB 字典與詞彙表規格進行驗證 --profile edupub = 以EDUPUB Profile進行驗證 --profile idx = 以EPUB 索引規格進行驗證 --profile preview = 以EPUB預覽規格進行驗證 ...以下省略...

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
EPub Checker指令工具十分友善地提供繁體中文的說明(help),也可以用來確認指令工具可以做到哪些事情,大幅降低新手使用的門檻。

2.4 執行EPub Checker

參考help的提示,使用--mode opf -v 3.0來指定檢查EPub規則的版本。不過,程式似乎能夠透過一些機制或設定,來辨別需要使用哪個版本來檢查。

# 書名: Java Persistence with MyBatis 3 by K. Siva Prasad Reddy (z-lib.org).epub

> java -jar epubcheck.jar --mode opf -v 3.0 "Java Persistence with MyBatis 3 by K. Siva Prasad Reddy (z-lib.org).epub"

由於會從EPUB檔案中取得模式與版本,將會忽略引數。
以EPUB 2.0.1 版本規則進行驗證。
ERROR(RSC-020): Java Persistence with MyBatis 3 by K. Siva Prasad Reddy (z-lib.org).epub/OEBPS/ch05.html(59,564): 「http://www.springsource.org/download/?community/」不是正確的 URI 。

檢查完畢,發現錯誤
訊息: 0 個致命錯誤 / 1 個錯誤 / 0 個警告訊息 / 0 個參考提示

EPUB檢查完成

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
若要進一步研究EPub Checker指令的功能,可以前往它的GitHub專案會有更詳盡的介紹。

3.圖形化工具

3.1 下載Pagina

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
可以依據個人所使用的電腦作業系統,下載相對應的版本。因為我使用Windows 10,所以本次測試選擇下載pagina-EPUB-Checker_Win-2.0.4.zip這個版本,並將其解壓縮。

3.2 執行EPub Checker

相較於指令工具,Pagina提供十分簡單快速的操作介面,僅需要指定EPub的檔案位置即可完成EPub格式的檢查。您會發現,輸出的結果是不是就跟指令工具一模一樣呢?

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

4.結語

其實不論是使用指令工具或圖形化工具,目的都在於校驗手工製作出來的EPub電子書是否符合所謂的「標準」,儘管範例的這本書在經過檢查後,會出現「不是正確的URL」的錯誤訊息,但它仍然不妨礙在電子書閱讀器或瀏覽器上正常閱讀。

進一步來談,許多電子書的製作人,其實並不怎麼需要在乎EPub是否合乎所謂的「標準」,不影響閱讀就好。但是,以長遠的角度來看,假設這個電子書存活的生命週期會長達10年、20年之久,隨著時間的推移瀏覽器、閱讀器的不斷升級改版,舊有錯誤所埋下的隱患是否會因此慢慢發酵?亦或者將來若有新的電子書格式,這些EPub是否也都能順利轉檔?