1 person found this helpful
You can try doing each replace in two steps, rather than 1. First apply the paragraph style; don't replace the text (not even 'with itself'). Then loop over it again and remove the <pstyle> tags.
that's how i do it now, as the script runs, it builds a list of tags that can be removed at the end.
the problem is when there is a error. for example if inside a paragraph there is a footnote, findGrep will ignore the said paragraph, and at the end when the script removes the tags, that paragraph will remain unprocessed, and also unmarked.
(ps. the footnote is just a example, that i actually fixed, but there can be any other kind of error that leaves a tag unprocessed)
What if you only remove 'correct' <pstyle> markings in the second run? I.e., only search for <pstyle:x> in the style 'x'? Then you'd only have <pstyle>s left that failed in the first loop.
yep, but the closing tags are killing me.. how do i know to remove the proper </pStyle>