integrate my own lib inside code-blocks of SimpleWiki

8 views
Skip to first unread message

kib2

unread,
Jan 27, 2011, 10:24:56 AM1/27/11
to simpl...@googlegroups.com
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' [http://kib2.free.fr/pastebin/index.php] 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.

Cheers:

Christophe K.

Henrik Bechmann

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

Best,

- Henrik

--
You received this message because you are subscribed to the Google Groups "simplewiki" group.
To post to this group, send email to simpl...@googlegroups.com.
To unsubscribe from this group, send email to simplewiki+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/simplewiki?hl=en.



--
bechmann.ca

Henrik Bechmann

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

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
text
...
}

Follow

callback_pre_html

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

$this->register_macro_callbacks(
array(
'quicktoc' => array($this,'macro_quicktoc')
)
);

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

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 http://dlml.org/gargoyle/demo.html), which is winding up (for
now). In a week or so I'll start on finishing the upgrade to the
Musterdb.org 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.

Best,

- Henrik
Reply all
Reply to author
Forward
0 new messages