I bet you could do the same thing with pandoc and skip serializing to HTML entirely.