Cut at a macros Plugin

I've got a first cut at a hopefully zen-of-blosxom macro package with most of the capability of Brad Choate's mtmacros.

right now, macros are defined with perl code -- it loads files from state_dir/.macros.

It supports

"string"
simple string replacement
"pattern"
regular expression replacement; $1-$9 are available to macros
"tag"
html-style tags without content (ie, <line width="30%">); attributes are available to macros, with defaults. $1-$9 are also available, if the name has ()s in it
"ctag"
html-style content tags (ie, <amazon asin="0434332333">Title</amazon>); everything from tag macros are available, plus the body

Replaced text can be either as-is ("${name}") or url-escaped ("$<name>").

The major missing feature is being able to apply macros only to content text, not to html markup. Also in mtmacros and missing are run-once, recursive, fold-case, and being able to enable or disable macros on a per-story basis.

There's too much repeated code right now, and I haven't started to optimize it yet, but any feedback on the syntax in particular is very appreciated; I think we're all better off with one really good macro package (whether it's based on this or not) than several almost-good-enough ones.

Anybody who wants to take this and run with it is encouraged. I'll get back to it sooner or later but think this is the kind of thing that a community can do better than one person.

URL summary:

2003-03-06 06:40:00 | Comments (3) | TrackBack (0) | Computers::Internet::Web::Blosxom

Trackback Pings

TrackBack URL for this entry:
http://molelog.molehill.org/~jtl/mt/mt-tb.cgi/547

Comments

Todd Larason

Updated URLs:

1969-12-31 16:00:00

Anonymous


It's a pretty neat setup, and very flexible, but I haven't gotten around to actually using it....

1969-12-31 16:00:00

Anonymous


I think I have Todd Larason's macros plugin set up to do smilies. (Partial blame should be placed at the feet of Mark Pilgrim. )

2003-03-28 00:40:00

Post a comment




Remember Me?

(you may use HTML tags for style)