Recent Changes · Search:

Support the Project



edit SideBar

Wikipublisher does not see/use Beautifier ouput
Raised by
Joshua K?
Date opened
Tuesday, 19 September 2006
Wikipublisher seems to have an allergy to the Beautifier plugin for PmWiki. When printing a page with Beautifier code, the text before and after the code will put in the PDF, but the rendered code itself is nowhere to be found.

Assistance in resolving this would be greatly appreciated, as putting code in our PDF’s is one of our must-have features.

See an example here:

Proposed solution
The problem lies in the way Beautifier produces output, which is to emit HTML tags. Wikipublisher works by causing PmWiki to emit output to the Wikibook DTD, rather than HTML. Any residual HTML tags, such as those which Beautifier introduces, are removed, and this will often produce unexpected results.

In general, PmWiki recipes that follow PmWiki coding conventions will play with Wikipublisher. This means recipes that emit either wiki markup or define variables for every HTML tag used. The general solution is to map the recipe output to the corresponding wikibook xml tags. The solution lies in the recipe, rather than in Wikipublisher. Unfortunately, while PmWiki itself is “markup agnostic”, many recipes are not. See Markups.

The best option appears to be to use the LATEX listings package, which is designed specifically to beautify program listings. It supports a wide range of programming languages.

As I did spend some time finding a solution, here is my proposal to save your time ;)
Install the sourceblock recipe together with the GeSHi package and the LATEX listings package. Then you only have to edit the cookbook/wikipublisher/latex/stdmarkup.php to add the (:source:) markup for LATEX generation. Here’s the code I added to this file:

## Sourceblock markup
function Latex Text Code?($args, $text) {
 $text = preg_replace(“/\n[^\\S\n]*$/”, “\n”, $text);
 $opt = Parse Args?($args);
 if(@$opt[‘lang’]) {
   return “<tbook:verbatim class=‘$opt[lang]’>”.Keep($text).”</tbook:verbatim>”;
 else {

  return “<tbook:verbatim>”.Keep($text).”</tbook:verbatim>”;
Markup(‘sourceblock’, ‘>markupend’,
   “Latex Text Code?(PSS(‘$1’), PSS(‘$3’))”);

Markup(‘sourceblockend’, ‘>sourceblock’,
   “Latex Text Code?(PSS(‘$1’), PSS(‘$2’))”);

## End of sourceblock markup

I hope that’s of some use ;)

Date closed

« 00093 · Edit Form · 00095 »

Creative Commons License
Edit · History · Print · Recent Changes · Search · Links
Page last modified on 05 November 2008 at 06:49 PM