At the moment the entangled pandoc filter is used to generated source code from Markdown, but since v1 entangled can also tangle. The entangled command can also be scripted making some of the shell hacks no longer that complex.
I would propose to switch to the entangled command.