ieure/sicp — pull request #5 by spiralman (2013-12-08 04:10:55+00:00)
Title: Make EPUB file Google Play Books compatible

This is a very large pull request, and goes in a slightly different direction than some of the previous work, so I don't mind keeping it as its own fork if you don't want to merge it.

My main goal here was to make the epub file compatible with Google Play Books. I used epubcheck (recommended by Google) (https://github.com/IDPF/epubcheck, also available as a web form at http://validator.idpf.org/) to identify issues, and most of the fixes were done automatically using sed or Python.

You can see most of the details in the commit messages. The large majority of the issues are fixes to references in the HTML files and in the TOC itself (removing % signs from the anchor IDs, fixing all the fragment identifiers in the TOC file to match actual IDs in the document and fixing a few other random references). I'm not sure what state of the source you were trying in iBooks, but the fragment IDs in the TOC were completely wrong, which might be why iBooks couldn't follow them (nothing should have been able to).

I also undid the work to break the chapters into sub-files (it was only done to one file, and the internal references weren't fixed; again, that might not have been the problem at all with iBooks?) and to do the SVG conversion (I just wanted something that worked, and having only 33% of the images was generating a lot of errors).

There are actually still a fair number of errors generated by epubcheck, mostly about HTML tags being used in ways that are apparently not allowed in EPUB (nesting paragraphs where they shouldn't be and things like that). I didn't go after those issues yet, since my goal was Google Play compatibility, not pedantically following the EPUB spec.

I looked into using http://dvisvgm.sourceforge.net/ to do the SVG generation, and got good output for the one file I checked by using the -n (font-tracing, not SVG font elements) option, so that might be a simpler way to go for SVG generation than generating raster images and using potrace.