Retext encoding and decoding between AST and object model