integrate my own lib inside code-blocks of SimpleWiki

Skip to first unread message


Jan 27, 2011, 10:24:56 AM1/27/11
Hi Henrik,

I'm starting to use SimpleWiki, and I'm rather new with PHP (not with programming, and in
fact I've already build several Creole like parsers, but that's another story.).

I would like to embbed my own syntax highlighting library 'Prism' [] by passing
all {{{...}}} code-blocks contents to Prism.

I'm pretty sure it's rather easy to do, but I've started PHP 2 weeks ago so it's not so obvious for me.
If you've got any hint, please tell me. I can give you Prism code if you want, but I'm sure it needs some polishing.


Christophe K.

Henrik Bechmann

Jan 27, 2011, 10:28:29 AM1/27/11
Thanks Chrisophe, good to hear from you. I'll look into this shortly.


- Henrik

You received this message because you are subscribed to the Google Groups "simplewiki" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at


Henrik Bechmann

Feb 6, 2011, 7:50:38 PM2/6/11
to simplewiki

It looks to me like the most direct option is to register a class
callback. Thus you would write

|:pre prettyprint:|{{{
// the source code

Register your code with

$wiki = new SimpleWiki();

$wiki->register_class_callbacks('preformatted' =>
array('prettyprint'=> array($myobject,'callback_pre_prettyprint')));

Your callback is handed the emitter node, which you can modify as
appropriate (including running the text through a processor). Your
code would be

public function callback_pre_prettyprint ($node)
// modify emitter node
$node->escapecontent = FALSE; // literal passthrough of generated



in native_simplewiki.php for an analog.

I believe the text output is in the $node->text property. I don't see
that I created any documentation for this, which I'll have to rectify.

If you really want to use a global macro instead, follow the
"quicktoc" macro (starting with

'quicktoc' => array($this,'macro_quicktoc')

at line 160 of native_simplewiki. But this will be very hard without

At the extreme end, you could extend any of the simplewiki classes as
discussed in a previous email here.

Hope this helps, or will do in the short run.

FYI I've been buried in browser interface stuff for the last while
(see, which is winding up (for
now). In a week or so I'll start on finishing the upgrade to the core code that I started last summer. During this phase
I'll review simplewiki. Will probably last to mid to end of March.

As discussed before I hope to add some kind of auto documentation
generation to all this, which should help.


- Henrik
Reply all
Reply to author
0 new messages