Jason Ross <jasonross1...@gmail.com> writes: > Here's a hook that modifies the source blocks to wrap their > output in #+BEGIN/END_METAPOST tags if the ConTeXt backend is used, > before Org Babel gets to them, but otherwise leaves them alone. > > I wonder if anyone has any better ideas of how to do this. I'm > modifying the Org source with the hook before the document gets parsed > so that it can be more backend-agnostic but it seems like it would > be better if there was a way to modify the document parse tree > directly instead. I don't like that I'm effectively parsing and > rebuilding (hopefully) the same string in order to change the :result > type.
I am not sure if there is an easy way. ob-exp gets run before backend filters and you do not yet have access to the document parse tree. You may consider a patch for ob-exp to get better control over code execution during export. Best, Ihor