If you're going to do this, why not generate Pandoc ASTs directly? You can do so from a number of languages and they support (by definition) a superset of any given markup's features, with blocks to call out directly for things you can only do in Latex.
I assume the original question is asking about programmatic document generation, in which case working with a real AST is probably also a productivity and reliability win as well.
I assume the original question is asking about programmatic document generation, in which case working with a real AST is probably also a productivity and reliability win as well.