Right, so what you could do is make a pandoc template that writes an m4 template just like my last example there.
Replies
Thanks for the suggestion, but after a month of monkeying around instead of writing I just gave up and went back to WordPress. :)