Extension:DocBookExport

The DocBookExport extension lets you create a DocBook from selected wiki pages. You can download the DocBook as an XML file. Other formats supported are ODT, HTML and PDF.

Configuration

 * Set the URL for the html to docbook script installed in your server. Eg. http://example.com/html_to_docbook
 * Set the URL for the html to docbook script installed in your server. Eg. http://example.com/html_to_docbook

Dependencies

 * Install the following dependencies on the same or different server, that would be used to handle the html to docbook generation:
 * "pandoc": See  for the latest version


 * For Ubuntu use the following commands, replace the version number as per the latest releas
 * Install xlstproc:
 * For Ubunutu install using: sudo apt install xsltproc
 * To download DocBook files in Zip format install the following software:
 * ZipArchive php extension: See https://stackoverflow.com/q/3872555/1150075
 * To download DocBook in PDF format install the following software:
 * "saxon": See http://www.sagehill.net/docbookxsl/InstallingAProcessor.html
 * Note that you need to also have the Docbook Saxon extension installed. See: http://www.sagehill.net/docbookxsl/InstallingAProcessor.html#InstallSaxon
 * "fop": See https://www.howtoinstall.co/en/ubuntu/xenial/fop
 * Install html_to_docbook as per directions in the README file


 * On the wiki, install the "Figures" extension - that supports defining figures in MediaWiki
 * Install mpdf in your MediaWiki installation using composer using the following command:

Usage
To create a book define the page structure using the docbook parser function or tag extension. See examples below.

Parser function example:

On saving the page a link will be generated which directs you to a special page Special:GetDocbook. The docbook request is then pushed to the same or other server handling html to docbook generation. Once the docbook is generated, links will be made available on the Special page to download the DocBook: in XML, HTML, ODT and PDF formats.

The parameters shown can be customized as follows:
 * is used to defines the wiki pages that will be part of the docbook as cover, sections and chapters. The first line starts with a  and indicates the preface,   indicates a page which contains multiple chapters, each chapter is specified using a h1 heading.   indicates a chapter and   indicates a section of that chapter. Sub-sections can be defined using   or   and so on. The last line again starts with a   and indicates the wiki page to be used as the appendix. Sometimes you may want to merge contents of multiple wiki pages to one section/chapter. For that you can add a comma separated list of such pages as well. You can also customize the title of such a section by adding the following wikitext   at the end of the line. Similarly you can customize the header/footer/header left and right/footer left and right for a specific section by using the   syntax at the end of the line as shown in the example. To change the orientation of a specific chapter or section add


 * This parameter defines the name of the Docbook. This doesn't relate to any wiki page and is only used to name the files and the title of the docbook.
 * This parameter specifies the wiki page to be used as the cover page.
 * This parameter specifies the header to be used for every page of the docbook.
 * This parameter specifies the footer to be used for every page of the docbook.
 * This parameter specifies the header on the left side of the page to be used for every page of the docbook.
 * This parameter specifies the footer on the left side of the page to be used for every page of the docbook.
 * This parameter specifies the header on the right side of the page to be used for every page of the docbook.
 * This parameter specifies the footer on the right side of the page to be used for every page of the docbook.
 * This parameter should be set to 1 in order to generate the index.
 * This parameter is a comma separated list of terms that should be indexed.
 * If you have wiki pages for all your index terms you can add them to a category and mention it here.
 * Lets you customize the orientation of the output format.
 * Lets you set the parameter section.autolabel.max.depth in Docbook.
 * Lets you set the color for external links for PDF.
 * Lets you customize the size of the page.
 * Lets you customize the number of columns.
 * Lets you customize the margin for each side of the page.
 * Adds a timestamp on the bottom-right part of the cover page with the following text: Produced from  on.
 * Lets you customize the font for the title of the PDF.
 * Lets you customize the font for the body of the PDF.
 * Lets you customize the font size for the body of the PDF. The font size for the footnotes would be 0.8 times this size.
 * Lets you customize the font family for footnote.
 * Lets you customize the font size for the footnote of the PDF.
 * Lets you add a watermark in the PDF. Watermark is a text used as a SVG image with additional options for styling the text.
 * Lets you customize the font size on the watermark in the PDF.
 * Lets you customize the font on the watermark in the PDF.
 * Lets you rotate the text on the watermark in the PDF.
 * Lets you customize the font color on the watermark in the PDF.
 * Lets you provide your custom XSL configuration files. This path would be replaced in the "DOCBOOKXSLPLACEHOLDER" path in the xsl template file instead of the standard docbook xsl files.
 * All rest parameters are self-explanatory Docbook element tags.

DocBook supports figures which are images or other media that can be referenced elsewhere in the document. A separate list of figures is also prepared. To define a figure you need to use the Figures extension.

Grouping of indexes is possible as well. To use this feature add the following wikitext to the index term page (create if required) specifying the group name:

Another approach to add grouping is by specifying a Semantic MediaWiki property which contains the group name, this can only be done for index term categories and can be specified using "group by" parameter as follows: While styling in wiki pages is easy using CSS, the same styling is not carried forward to the Docbook. This can be a problem with tables which sometimes should have different widths for different columns. To solve this you can specify a class with the following format: colwidth-80-20, the extension will then convert it to the following Docbook XML which ensures that the column width is maintained in the Docbook:  
 * index term categories=index terms(group by=Index has Group)

Similarly, for a three column table specify the class as "colwidth-80-10-10"

Credits
This extension has been written by WikiWorks.

Development and Help
You are welcome to submit bug fixes in Gerrit and bug reports and feature requests in Wikimedia Phabricator under tag/mediawiki-extensions-docbookexport.

Please also feel free to contact the author or WikiWorks for consulting on further developments, feature requests or bug fixes on this extension.