Better way to replace styles (in a table)

This forum is for all Flare issues related to styles, stylesheets and XML.
Post Reply
Sean
Propeller Head
Posts: 57
Joined: Mon Apr 14, 2014 7:45 am

Better way to replace styles (in a table)

Post by Sean »

I imported from FrameMaker into an HTML 5 project that was empty but for which I had created some styles (CSS) for mapping to.

I mapped to. However, my table styles were not presented for mapping. I wanted to map TableBodyCtr to p.TableBody, for example. p.TableBody was there, but the import never prompted me to map the TableBody FM styles.

So, after I opened the result and looked at the HTML, I have the following. Note that a "TableBodyCtr" class is mentioned but does not actually exist. It's the old FM style name. And, I chose to not retain FM styles in the conversion.

https://www.dropbox.com/s/3n0vwddeiu949 ... e.png?dl=0

So, I found that I could click in a cell, right click the "p" item in XML view, and then select Style Class and choose the class I wanted. But, I had to do this for each and every cell, and apparently each and every table. This will stink.

https://www.dropbox.com/s/2e1w7pp0z668e ... e.png?dl=0

Here is the result of my work on a small table. Notice the class is p.TableBody.

https://www.dropbox.com/s/sgsdrr6fnugto ... r.png?dl=0

So, how can I more efficiently retag this table content. Selecting the p tag in XML Editor for each and every cell and making the change is tedious.\

Advise?

Cheers,

Sean
cubreporter51
Jr. Propeller Head
Posts: 7
Joined: Wed May 31, 2017 5:44 am

Re: Better way to replace styles (in a table)

Post by cubreporter51 »

You can use the "Find and Replace in Files" feature to replace source code with new source code.

First, I'd make a copy of your project to test it out, so that you can have something to revert to if the find/replace behaves differently than you expected it to.

Then, try these steps:
1. On the Home tab, click on the Find and Replace in Files option (over toward the right end of the ribbon).
2. Under "Find:" type in the following: <p class="TableBodyCtr"
3. Under Replace with: type in the following: <p class="TableBody"
4. For Find in: pick one of the options (I tested it in a single file, you could try a page, folder or your whole project, since you have a backup)
5. You can pick the File Types (I left mine as All, since I only did "current document")
6. Under Find Options, make sure you check off the option "Find in source code"
7. For Result Options, Replace All.
8. Click OK to the warning dialog.
9. Enjoy your quickly replaced classes. :)
Sean
Propeller Head
Posts: 57
Joined: Mon Apr 14, 2014 7:45 am

Re: Better way to replace styles (in a table)

Post by Sean »

I will give that a whirl and report back. Cheers and thanks!
Sean
Propeller Head
Posts: 57
Joined: Mon Apr 14, 2014 7:45 am

Re: Better way to replace styles (in a table)

Post by Sean »

It was a good idea. Search didn't work reliably, however.

For example, i searched for the following. Understand that I could see this in the html code and could copy it from the code and paste it into the find field, but Find Next did not find it.

<col width="348px" class="TableStyle-IDTable-Column-Column2" />

Since it cannot find that text, which is obviously there, I cannot trust the find not to mess up in other places.

I was searching in the "(whole project)," for "All Files" ("HTML" was not an option), "Regular Text, Find in Source Control.

Thanks for the suggestion, though. I might consider using FAR or some other tool.

Sean
cubreporter51
Jr. Propeller Head
Posts: 7
Joined: Wed May 31, 2017 5:44 am

Re: Better way to replace styles (in a table)

Post by cubreporter51 »

Sorry I couldn't be of more help.

You're right, if your source code to match has several varieties, you either have to find a way to use wildcards or try something else.

You could add a small JQuery script reference in your pages and write a script that removes whatever class is on the table <p> elements, then add the right class. It would only show up when the page is rendered in a browser, and wouldn't fix the source.

I've tried both things with mixed results. The JQuery solution works when you have someone consistently submitting content to you from Word, because MS inserts so much garbage inline styling. That was my situation for using it. I would get revisions with the same stuff re-inserted every time the person saved, so I just wrote a script for that content that removed that styling and added my classes when the page was loaded, because it was easier than editing the source.

Search does always seem to miss something, but usually does enough that you think it worked everywhere, only to publish your content and find that it missed a key spot.

Hope you find a solution that works!
ecjoe
Propeller Head
Posts: 85
Joined: Fri Aug 02, 2013 10:33 am

Re: Better way to replace styles (in a table)

Post by ecjoe »

I typically use Notepad++'s Find in Files feature to find and replace variable text. Set the search mode to regular expression. If you are unfamiliar with regular expressions, perhaps you can ask a developer to help you out. Here is a great resource for learning and testing regular expressions: http://regexr.com/

I would strongly suggest that you perform the following before finding and replacing across all of your files:
1. Back up the files in question.
2. First perform a "Find All" instead of "Replace in Files." Review the search results and verify that it is only capturing the results that you want.
Joe
(Flare 2017 r2 - Windows 7 64)
Sean
Propeller Head
Posts: 57
Joined: Mon Apr 14, 2014 7:45 am

Re: Better way to replace styles (in a table)

Post by Sean »

I am generally using Notepad++ now to fix code. Working great. Thanks all.
Post Reply