[pmwiki-users] formatting pre-formatted text!

Stirling Westrup sti at pooq.com
Sun Sep 3 00:42:30 CDT 2006

Mohamed El Dawy wrote:
> Hi,
>  First, thanks a lot for doing PMWiki. I really love it. It is amazing.
>  I am trying to include a few lines of source code on my wiki page, so i
> put them in a preformatted tag like this...
> [@
>    source code goes here
> @]
> Now, here is the tricky thing. I am trying to make certain lines of the
> code bold. I need this to point out the changes made to a previous piece
> of code. Now, if i try this...
> [@
>    ''' cout<<"hello world"<<endl; '''
> @]
> the line of code is displayed with 3 quotes before and after (not made
> bold).
> is there anyway to achieve this? I have to use the preformatted tag to
> preserve the indentation.

First I should mention that there are at least two cookbook recipes for
making this sort of thing be a bit easier. They are the code beautifier:


and the SourceBlock markup:


I have found that when doing large amounts of code publishing these are
worth while but a bit of a pain when just illustrating a few short
snippets. In that case I find it useful to define something like a
codeblock wikistyle:

  %define=codeblock block white-space=pre font-family=monospace

Then you can use the wikistyle to display your code as you wish:

%codeblock% '''grep''' ''pattern'' ''file''

For larger blocks, you stick it in a div markup:

#include <stdio>
'''cout<<"hello world"<<endl;'''

See the Wikistyles documentation for examles of how you can add
distinctive borders and background colors to codeblocks as well, if you
would like.

More information about the pmwiki-users mailing list