Refactor pandoc filter.