DOCX parsing
Published on 10/10/2026
- python-docx could parse the DOCX files
- Create required data classes. Nested classes fro AST, but need not store all details library provides
- python-docx result need to be parsed recursive descentant manner, for converting to data classes
- On data classes, do transformations like converting to Markdown, trimming spaces etc.
- Also provide convertion from AST back to DOCX
- In addition to AST <—> DOCX, AST <—> JSON is useful for visualizing in browser & editing in text mode
- Serialize/deserialzie data class to JSON. Nested deserialization requires some custom handling
Thoughts
- Probably python-docx has a similar AST internally