I want to compile a docx file into a Typst file, I believe deep down docx is XML, and Typst is close to markdown with interesting functionalities, is that feasible? Note that Typst does have syntax to define functions and call them and I want to create special functions during the code gen step, is ANTLR the right tool for the job? Are there better tools? I want to have as few bugs as possible
Antlr sounds excessive for either of those. Use an ordinary xml library for docx (if there’s not already one for docx) and something simple for typst.
I want to compile the docx INTO a typst file, not a separate parser for each
Oh, ok, antlr would be inappropriate then. I’d check whether pandoc already does that conversion.
I just checked, it does convert to Typst but I do want to write custom stuff alongside what pandoc will output, that seems like the right tool and saves me a lot of efforts, thanks
ANTLR is for writing parsers. You don’t need a new custom parser, just use an existing XML parser.
I don’t know anything about Typst, but I do know that .docx files are really just a zip file containing a folder structure with a bunch of xml (and a few other) files. I’ve written a few find/replace docx scripts in bash utilizing this information.
Since the source is XML XSLT may work to transform it.