Now I think I understand:

What do you see as the benefits of translating into a javascript PRDocument type structure? 

I guess won't have to worry about escaping the text...