[pmwiki-users] Content/Music - preprocessor step

Martin Fick mogulguy at yahoo.com
Fri Feb 15 12:35:15 CST 2008

--- Patrick Ogay <lists at basel-inside.ch> wrote:
> I'm trying to extend the (:abcm:)  to use a
> preprcessorstep - abcpp
> I looked at the script and I found a place where the
> scripts are assigned.
> ContentRegFSConverter("abcm",   "midi", 'abc2midi
> ${i} -o ${o}');

Yes, you want to mimick this.

> Does it make sense to pipe, Soemting like here
> ContentRegFSConverter("ppm", "gif", 'pnmcrop < ${i}
> | ppmtogif > ${o}');
> But it seems to be better to me to have a separate
> step. Actually I don't understand how the processing
> sequenz is controlled.

To start with you will probably want to register a new
type for the preprocessor markup, like this:

ContentRegisterType('abcpp', 'text/plain', 'abcp',
$MUSIC_LIST, true);

The last "true" in this statement creates a new pair
of (:abcpp:) and (:abcppend:) directives allowing you
to create abcpp content in your wiki pages.  But this
just allows you to get the content recognized by the
system,  it does not actually do anything with it.  

Next you will need to tell the system what other types
can be created from this abcpp type and how.  Since
the music recipe already has two types that you might
want to get out of this preprocessor (abcm or abctab),
you can register FS (filesystem) converters which take
abcpp and create abcm and abctab.  This would look
something like this:

ContentRegFSConverter("abcpp", "abcm", 'abcpp < ${i} >
ContentRegFSConverter("abcpp", "abctab", 'abcpp < ${i}
> ${o}');

That would normally be all you need to do, but
unfortunately from looking at abcpp it seems like you
will want the ability to pass various arguments to
this converter for it to actually be useful.  For this
you will probably need a more advanced content
converter than the built in FS converter, one that can
safely pass user arguments to command lines.  I stress
safely here because if not done right it would be easy
for a malicious user to inject random unix commands to
the command line.

While this would not be too hard to code up as your
own specialized converter (use the function
ContentFSConverter() as a guide), I will also give
this some thought to see if the content API could be
enhanced to make this sort of thing easier (now that I
have a real use case for it).

If however you simply wanted to use the abcpp to write
combined abcp markup that gets split into abcm and
abctab, perhaps hardcoding the default macros ABCM and
ABCTAB is all you need?  Like this:

ContentRegFSConverter("abcpp", "abcm", 'abcpp -ABCM <
${i} > ${o}');
ContentRegFSConverter("abcpp", "abctab", 'abcpp
-ABCTAB < ${i} > ${o}');

Then in your abcpp markup you can outline ABCM only
sections with #ifdef ABCM ... #endif, and ABCTAB
sections with #ifdef ABCTAB ... #endif, make sense? 
You can see an experimental example of this here:


Click on the abctab link to see that it indeed has a
different comment (:w lyric) at the bottom.


Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  http://tools.search.yahoo.com/newsearch/category.php?category=shopping

More information about the pmwiki-users mailing list