I would like to see the following question re-opened, which I just came across:
This has been closed for the reason: "too broad [...] too many possible answers, or good answers would be too long for this format".
After having seen the same user posting in the Pandoc discussion forum in Google Groups, I now know how to answer his question perfectly well, and the gist of it will be very short: I'll use a pipeline of Pandoc and
grep commands to achieve the desired output. The answer fits into a single Tweet, I promise!
(I've also tried to improve the wording of the question text and headline -- but it needs to go through review first...)