Macro implementation sample.

0 views
Skip to first unread message

Alex Korobkov

unread,
Feb 19, 2011, 2:56:49 PM2/19/11
to simplewiki
Henrik,

Can you please share some example of how to implement custom macro?
All thouse hash arrays and call back functions puzzles me. :)

I also have few questions about the implementation:

In particular I am interested on do incoming arguments get parsed if
they have some wiki markup? And how about output text - will it get
parsed further?

If I have to register each macro function - does it mean that for
every page on my site the server has to load each macro function, even
if page does not call any?

Thanks in advance,
Alex.

Henrik Bechmann

unread,
Feb 23, 2011, 2:32:50 PM2/23/11
to simpl...@googlegroups.com
Hi Alex,

The only example of a macro that I have at the moment is the quick toc macro (Native_SimpleWiki::macro_quicktoc($node)), the implementation of which you can find in the Native_SimpleWiki module.

The macro callback function is passed a pointer to the macro node, by the emitter, meaning that all parsing has been completed (the document tree has been created) and emitting has been processed to the point of this node. The entire tree can be traversed by the macro method through parent and children properties of the macro node.

The macro code implements its effects by modifying these document tree nodes as needed to get desired results. You'll see that my quicktoc macro (warts and all), actually generates some wiki markup, calls another instance of simplewiki to process it, and then jams the resulting html in the node's "output" property.

What properties are available on a node and how should they be modified you ask?? <grin> I'm currently working on documenting this whole thing, and I will release the documentation within days or at most weeks. Best I can do for now.

Since the macro is called by the emitter, no further parsing (other than some link parsing from what I can see - this will also be documented) takes place at this stage, unless you call the parser yourself, as I have done with the quicktoc macro.

When the macro function is registered, php just passes a pointer. However the macro function would of course have to be loaded in memory for the pointer to be available, so if you want to avoid that you'll have to think of a way of making those decisions outside the simplewiki scope.

Hope this helps a bit. I'll notify here when I publish documentation. I'm using Doxygen and it's going pretty well, so I should be able to just copy the generated html documentation pages to the simplewiki.org website. And since the documentation is generated from structured annotation, the code will itself be better documented.

In general I'm currently working toward an RC1 release (release candidate 1).

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

Alex Korobkov

unread,
Mar 3, 2011, 8:05:13 AM3/3/11
to simplewiki
Thank you, Henrik!

Will wait for your RC1.

Alex.
Reply all
Reply to author
Forward
0 new messages