I would like to be able to add charts and tables at specific locations in a MS Word document based on a template, using Officer's body_add function.
Since text in ms word can get chunked, is there a way to search for the expected text using regex, taking into account possible chunking?
For example, I am expecting: xyzChart 1
But the actual chunk in my template (shown by docx_show_chunk) seems to be:
3 text nodes found at this cursor.
<w:t>: 'xyz'
<w:t>: 'Chart'
<w:t>: ' 1'
Is there a way to search for something that might look like this in the Word template?
I realize that a possible solution is to make sure that the template document never contains chunks like this, but it seems more robust to me to assume that things like this can happen and to account for it in my code.
If there is a better way to provide a reproducible example for this, please let me know. Thanks in advance.