Saturday, August 6, 2011

Epub Check

‹prev | My Chain | next›

I am still not settled on the exactly how I want to generate mobi formatted versions of SPDY Book. If nothing else today, I would like to ensure that my epub formatted version is solid. To that end, I am going to give epubcheck a whirl.

Sadly, I already have Java installed. So my next step is to download the most recent zip file of epubcheck:
➜  Downloads  wget http://epubcheck.googlecode.com/files/epubcheck-1.2.zip
Google code is pretty cool in that the downloads have SHA1s associated with them, so I do a quick sanity check:
➜  Downloads  sha1sum epubcheck-1.2.zip 
86036eadad8408070791b3da368958239ed8a410  epubcheck-1.2.zip
Yup. Looks good. No unexpected Java code will be running amok on my system.

Next I install:
➜  Downloads  cd ~/src 
➜  src  mkdir epubcheck
➜  src  cd !$
➜  src  cd epubcheck
➜  epubcheck  unzip ~/Downloads/epubcheck-1.2.zip 
Archive:  /home/cstrom/Downloads/epubcheck-1.2.zip
inflating: epubcheck-1.2.jar       
inflating: COPYING.txt             
inflating: README.txt              
inflating: jing_license.txt        
creating: lib/
inflating: lib/jing.jar            
inflating: lib/saxon.jar           
With epubcheck unzipped in $HOME/src, I create a script named epubcheck to run it from $HOME/bin/:
#!/bin/sh

java -jar  $HOME/src/epubcheck/epubcheck-1.2.jar $1
Now, let's see if there are any errors in the epub version of The SPDY Book:
➜  output git:(master) ✗ epubcheck book.epub 
Epubcheck Version 1.2

ERROR: book.epub: resource OEBPS/stylesheets/handbookish.css is missing

Check finished with warnings or errors!
Well, not too bad. What the heck is handbookish.css?

It is nowhere to be found in my local repo for SPDY Book. Maybe it's a part of git-scribe? Hrm... I don't see it there either. Maybe it's generated by git-scribe. Acking through the code, I find reference to it in the test suite, but running the test suite I get two failures on the two lines asserting that handbookish.css should be present:
➜  git-scribe  ruby ./test/gen_test.rb
Loaded suite ./test/gen_test
Started
....FF.
Finished in 12.275742 seconds.

1) Failure:
test_scribe_can_generate_single_page_html(#<Class:0x00000001158000>) [./test/gen_test.rb:23]:
Failed assertion, no message given.

2) Failure:
test_scribe_can_generate_site_html(#<Class:0x00000001158000>) [./test/gen_test.rb:38]:
Failed assertion, no message given.

7 tests, 18 assertions, 2 failures, 0 errors, 0 skips

Test run options: --seed 23414
Commenting out the lines asserting that handbookish.css should be present makes the suite pass. A little investigation and I find that asserting that the scribe.css is present works:
test "scribe can generate site html" do
  in_temp_dir do
    @scribe.init('t')
    Dir.chdir('t') do
      data = @scribe.gen('site')
      out = Dir.glob('output/**/*')
      assert out.include? 'output/index.html'
      assert out.include? 'output/the_first_chapter.html'
      assert out.include? 'output/the_second_chapter.html'
      assert out.include? 'output/image'
        assert out.include? 'output/stylesheets/scribe.css'
end
end
end
I also root through the remainder of the git-scribe source, replacing handbookish.css with scribe.css. After reinstalling the gem, regenerating the epub, now epubcheck works:
➜  output git:(master) ✗ epubcheck book.epub 
Epubcheck Version 1.2

No errors or warnings detected
Ah better. I have put off my mobi toolchain issues for a day, but I feel much better about the epub that I am generating. Now if I could only get an iPad to see how it works in iBooks I might be iSatisfied (so sorry). Maybe tomorrow.


Day #105

1 comment:

  1. Chris Strom wrote:
    > Sadly, I already have Java installed.

    lol

    ReplyDelete