Originally committed to SVN as r6588.
This makes it easy to make it a macro in addition to an export filter, and simplifies the implementation. Originally committed to SVN as r6586.