schacon / git-scribe

basically the best way to write an ebook
MIT License
1.35k stars 121 forks source link

PDF Pygments #46

Closed eee-c closed 10 years ago

eee-c commented 12 years ago

I realize that this is a big shift, but I thought it worth pinging you on...

I recently got PDF highlights with pygments working. A sample generated with pygments is available at: http://gamingjs.com/building_avatar_sample.pdf

This offers four advantages over the current saxon/xslthl approach:

  1. No java. Intrinsic distastes aside, this makes for fewer dependencies (we can also replace source-highlight with pygments).
  2. More languages supported. The list of xslthl supported languages is embarrassingly short.
  3. Configurable themes. I have hard-coded the "borland" theme, but that could easily become an option.
  4. Better page control. This may just be me, but I could not get saxon to generate 9x7.5 inch pages (required by the prags).

Some notes about the implementation: I am decorating both the docbook and XSL-FO outputs on disks. The actual pygmentation reads in the entire XSL-FO document, extracts code snippets, sends them to a pygmentize system call, then converts the result to XSL-FO. It's a bit awkward, but it works.

I don't think you want this entire pull request as it has lots of differences - all are improvements, but that's besides the point :P

It would take a lot of effort for me to retrofit my changes back onto upstream at this point. If you're open to shifting back to xsltproc, then I will move forward with getting a series of PRs ready. If not, no worries -- I'm happy to maintain my awesome fork :)

A couple of other notes about that sample PDF: I pulled in admonition icons to make the callouts nicer. I have also added support for nicer fonts.

matthewmccullough commented 12 years ago

Looping in @jm and @erebor for sentiments.

eee-c commented 12 years ago

FWIW this also worked on my much larger Backbone book. Excerpts are linked from http://recipeswithbackbone.com/toc.html.