Search the Community
Showing results for tags 'tagged text'.
I've had some difficulty using Find&Replace to apply styles to tagged text on import, but found a solution that worked. This is somewhat more involved than the Find&Replace recipe which has been posted on several threads here, and may help someone with similar difficulty. Publisher 22.214.171.1241 My import text is a very simplistic HTML-like structure with free line breaks, which Publisher imports as paragraph breaks. <h1>This is a sample header</h1> <p> This is a line in a paragraph, which continues on a 2nd and 3rd line. </p> When I place such a tagged text file (.txt) in a Publisher text frame, the first thing I do is find and replace all the paragraph breaks with single spaces. Find: para-break Replace: space Obviously the actual paragraph break and space characters are used in the RE patterns, but I'm spelling them out here to be clear. Then I use an RE that captures end tags together with any surrounding spaces and replaces them with the end tag, spaces stripped off, and adds a paragraph break. Find: space*(</.*?>)space* Replace: \1 para-break Then for each tag, I use an RE that strips off the start and end tags and any superfluous white space and applies the appropriate paragraph style Find: <p>\s*(.*?)\s*</p> Replace: \1 (Format with Body) Similarly for <h1> and Heading 1 and the other tags. So, why did I do it this way? Why didn't I just strip off the tags and superfluous spaces, apply the styling and add a paragraph break in one step, combining my 2nd and 3rd Find&Replace steps? The answer is simple: It doesn't work! When I apply the 2nd tag style, the style is also applied to the adjacent paragraphs previously converted to the 1st tag style. I tried both "para-break \1" and "\1 para-break" as replacement patterns, but neither leaves the previously converted text alone. The solution is to introduce the paragraph breaks first to separate all the paragraphs cleanly, before styling each paragraph. Trying to chop out paragraphs and style them at the same time using Find&Replace is not "stable", at least in this version of Publisher.