style mapping/changing

This forum is for all Flare issues related to styles, stylesheets and XML.
Post Reply
cayennep
Sr. Propeller Head
Posts: 394
Joined: Mon Jul 26, 2010 3:42 pm

style mapping/changing

Post by cayennep »

I don't see a way to do this in Flare, but asking here in case others have resolved any of this

Unfortunately, the import doesn't allow you to map x style in Word to x style in Flare, so I've ended up with lots of cruft. The style mapping dialog is not clear, but it doesn't actually work and there's a bug for this.

Now that it's in Flare, I can't find easy ways to get rid of the cruft, so any suggestions appreciated.

** 1. I'd love to be able to map xcruft style to Flare xstyle - looks like this is only possible manually, changing it everywhere I find. Any magic?

** 2. If I change a style name, the old one is still used so it's not really changed. Is there a way to do this and have it stick? You can change stuff in Flare many different ways, but it's not always clear what's inherited and where to change it that will actually work - plus sometimes it just doesn't change, and I have to make the changes multiple times before it suddenly sticks. So any help, to avoid trial and error, would be welcome.
ajturnersurrey
Sr. Propeller Head
Posts: 348
Joined: Fri Nov 05, 2010 3:30 am

Re: style mapping/changing

Post by ajturnersurrey »

You might want to do a find and replace across all topics?

If I have a style I don't want, say

p class="obsolete"

I want them all to be

p class="justright"

I go and open one of my topics (any will do) in the Internal Text Editor format, choose 'find and replace' 'p class="obsolete"' with 'p class="justright"' and tick the box 'find in source code'. (Note I usually need to float the find and replace window and resize it to see that these tick boxes exist). I choose find in 'whole project' file types 'topics' and press the start button.
cayennep
Sr. Propeller Head
Posts: 394
Joined: Mon Jul 26, 2010 3:42 pm

Re: style mapping/changing

Post by cayennep »

ah, very clever! didn't think of that, which is exactly why I posted here, thanks so much
getting into the code solves the issues I frequently have of changing things in the WYSIWYG and having the changes not apply, or having to do it multiple times before it 'sticks' (very odd)

And, it sounds like Flare has improved the search and replace since version 7, when I last used it, if you're confident this works, so again thanks kindly!

However, I first have to see how these funky styles are used, to determine the pattern & what to replace them with, but it's really helpful to have a path instead of just trying everything!
LTinker68
Master Propellus Maximus
Posts: 7247
Joined: Thu Feb 16, 2006 9:38 pm

Re: style mapping/changing

Post by LTinker68 »

I recommend you search just on class="obsolete" and replace with class="justright". The reason I say this is because the class attribute may not come immediately after the opening tag (i.e., if you searched on p class="obsolete"). For instance, if there's an auto-number format in there then that attribute might be between the tag and the class attribute. In that situation, the find wouldn't work as ajturnersurrey wrote it because it failed the search parameters, so you'd still have a class="obsolete" in your project.
Image

Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
cayennep
Sr. Propeller Head
Posts: 394
Joined: Mon Jul 26, 2010 3:42 pm

Re: style mapping/changing

Post by cayennep »

thanks, LTinker, great tip!
I'm sure it will save me a lot of time and confusion, makes sense - so appreciate having these tips to do things right the first time, thanks all!
cayennep
Sr. Propeller Head
Posts: 394
Joined: Mon Jul 26, 2010 3:42 pm

Re: style mapping/changing

Post by cayennep »

ok, now getting into this and it's a bit more complex

there are a lot of cruft styles & classes, and how do I get rid of the closing tag, esp if it's </p> ??

esp the tables are really messed up, and ideally I'd like to lose the <p> tags inside <td> tags, but suspect I'll have to do that manually
LTinker68
Master Propellus Maximus
Posts: 7247
Joined: Thu Feb 16, 2006 9:38 pm

Re: style mapping/changing

Post by LTinker68 »

cayennep wrote:there are a lot of cruft styles & classes, and how do I get rid of the closing tag, esp if it's </p> ??
If you just want to get rid of the class, then don't include the tag in the find-and-replace -- just use class="whatever" and replace it with nothing.
cayennep wrote:esp the tables are really messed up, and ideally I'd like to lose the <p> tags inside <td> tags, but suspect I'll have to do that manually
You can look into wildcards or regular expressions if you want to do it in one fell swoop, but you might be able to do it in stages by first finding on <td><p> and replacing with <td> then finding on </p></td> and replacing with </td>. I'd make a backup of the project first and I wouldn't try to open a topic or do anything in between the stages, because if you do, you'll get errors about there not being an opening tag to match and ending tag or vice versa, or however Flare words it.

Or use a different find-and-replace tool. Several people have recommended FarHTML (I think that's its name).
Image

Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
cayennep
Sr. Propeller Head
Posts: 394
Joined: Mon Jul 26, 2010 3:42 pm

Re: style mapping/changing

Post by cayennep »

hm, ok, have worked with regular expressions before but didn't think Flare could handle it

trouble is, there's often a </p> tag and then a return, or arbitrary number of spaces, before the </td> tag

but a real tool would be able to handle that so will have a look

thanks!
nickatwork
Sr. Propeller Head
Posts: 457
Joined: Thu Sep 16, 2010 6:31 am
Location: London

Re: style mapping/changing

Post by nickatwork »

regular expressions in flare can definitely help with that. I've done it a few times to find </p> tags when doing something similar to what you are doing now, I think \s+ should help.
LTinker68
Master Propellus Maximus
Posts: 7247
Joined: Thu Feb 16, 2006 9:38 pm

Re: style mapping/changing

Post by LTinker68 »

cayennep wrote:hm, ok, have worked with regular expressions before but didn't think Flare could handle it
It can find with regular expressions, but I don't think it can replace with regular expressions, or something like that. Unless that was changed in v8. I seem to recall there was some problem with regular expressions so most people used an external program to make the changes.
Image

Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
crdmerge
Sr. Propeller Head
Posts: 248
Joined: Tue Dec 16, 2008 5:37 am

Re: style mapping/changing

Post by crdmerge »

FAR (http://helpware.net/FAR/help/hh_start.htm) is a top-notch Find/Replace tool. Not only can you work with regular expressions, but you can combine them with user-defined variables (such as for replacing start and end text but retaining what's in between). You can maintain Saved File Lists and Search Definitions for repetitive tasks.

It is robust and dependable, hands down, and is worth every penny. Oh, and its owner, Rob Chandler, is very gracious in answering stupid questions. :wink:


Good luck,
Leon
cayennep
Sr. Propeller Head
Posts: 394
Joined: Mon Jul 26, 2010 3:42 pm

Re: style mapping/changing

Post by cayennep »

ok, will give it a try, thx

esp as I realized that search and replace in Flare stops after a single change if the tags are incorrect (eg closing tag).

then, it breaks - and I can't publish. so not the way to go for any complex find and replace work
cayennep
Sr. Propeller Head
Posts: 394
Joined: Mon Jul 26, 2010 3:42 pm

Re: style mapping/changing

Post by cayennep »

So Far HTML works great, and I can probably rewrite the last search/replace step or just leave it off when I run the other steps on the backup I created before trying this.

However, the last step broke things - I think <td> some text </p>, which there's no way to fix in Far that I can imagine - and so of course Flare just stops working.

So Flare doesn't provide any info or fixes for syntax errors, correct? In this case it's too many files so makes sense to redo the search and replace, but wonder if there's a way around this? If a single file has a syntax error, there'd be no way to know which one it is, which is a bit worrying.

any tips appreciated, thx
crdmerge
Sr. Propeller Head
Posts: 248
Joined: Tue Dec 16, 2008 5:37 am

Re: style mapping/changing

Post by crdmerge »

Show us a few samples of the kind of code you're working on (bad old version, expected new version, actual broken new version, etc.)


Good luck,
Leon
Post Reply