[dokuwiki] Re: Building a book from DokuWiki

  • From: Michiel Kamermans <pomax@xxxxxxxxxxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Mon, 26 Apr 2010 13:13:11 -0700

On 4/26/2010 12:30 PM, holmberg_jason@xxxxxxx wrote:
Before I begin, I want to ask the community: how would you approach this? Does 
some of this functionality already exist in the form of plugins? Has anyone 
else done this?

I went with not trusting the internet to get typesetting right. Fourty years of digital typesetting has pretty much proven that the only technology worth trusting when you want to compile something into a book is to rely on technology specifically designed for the purpose of typesetting books - this means either (La)TeX, or DocBook (previously sgml+dsssl, these days xml+xsl:fo).

I went with TeX, since it offers the greatest typesetting and styling control. I wrote a series of simple PHP scripts that aggregate my dokuwiki data into a single book tex file, and massage the data a bit so that quotes and commas look proper etc., then I run that through xelatex (a fully unicode aware version tex, supporting the latex macros). The result of this is a publication-ready book, but it does mean making sure that the .tex code that comes rolling out of your conversion scripts will generate what you wanted it to generate; a real book goes well beyond simply turning html pages into pdf =)

To illustrate the result of the process, my dokuwiki is on http://grammar.nihongoresources.com and the book that is generated (with a single shell command, "texate --runlatex") is the .pdf file that's listed in the "download the book" section.

I've tailored the scripts to suit my dokuwiki, of course, but if there's interest I can put the scripts somewhere so that people can look at them and think about a way of possibly integrate that functionality into their own dokuwikis, or convert what it does into plugin behaviour (although that would probably be a bad idea, since compiling enough content to constitute a book into pdf form generally takes longer than php scripts are allowed to run, so "unsafe" php code would be required to make it run as plugin).

On a purely practical note, if you're writing a book that you want indices and glossaries in, you'll need to come up with a way to include code for that in your dokuwiki in a way that lets you add a filter pattern to the html renderer. I use {index:language:term} for instance, which is then filtered out when a page is xhtml rendered.

Hope that was somewhat along the lines of the kind of answer you expected.


- Mike "Pomax" Kamermans
--
DokuWiki mailing list - more info at
http://www.dokuwiki.org/mailinglist

Other related posts: