getting rid of empty spans

This forum is for all Flare issues related to styles, stylesheets and XML.
Post Reply
chrisklein
Jr. Propeller Head
Posts: 4
Joined: Wed Nov 14, 2007 2:20 pm

getting rid of empty spans

Post by chrisklein »

I imported MS Word into Flare and noticed that I have a lot of empty spans in the text.
An example is:

Code: Select all

...In the <span><span class="gui">Online Monitor</span></span> go to...
These empty spans are unnecessary, make the source harder to read and poison my text. Also cursor movement in the WYSIWIG view is even more clumsy.

Is there an easy way to get rid of the empty spans?
RamonS
Senior Propellus Maximus
Posts: 4293
Joined: Thu Feb 02, 2006 9:29 am
Location: The Electric City

Re: getting rid of empty spans

Post by RamonS »

Welcome to the forums!

Since one usually uses the span to apply a style to only a piece of text getting rid of the opening empty tags should be fairly easy as you can do a find & replace in source. But that is only half of the solution if not less, because you need to get rid of the excessive closing tags as well. You could try and see if searching for "<span><span>" and replacing it with "<span>" works out, but it may replace the closing tags of two legitimately intertwined spans with just one. I still think it is worth a try. Make a backup of your entire project before you take out the big fork and start picking at it.
chrisklein
Jr. Propeller Head
Posts: 4
Joined: Wed Nov 14, 2007 2:20 pm

Re: getting rid of empty spans

Post by chrisklein »

Tnx for the suggestion. I already do it with manual find/replace but with hundreds of topics this is very cumbersome, error-prone and time-consuming.
I would wish that Flare/analyzer is doing it or you have a script that can iterate over topics for such purposes.
RamonS
Senior Propellus Maximus
Posts: 4293
Joined: Thu Feb 02, 2006 9:29 am
Location: The Electric City

Re: getting rid of empty spans

Post by RamonS »

It does! You need to select in the search options to replace in all files. See this help topic:
http://www.madcapsoftware.com/support/w ... eature.htm
chrisklein
Jr. Propeller Head
Posts: 4
Joined: Wed Nov 14, 2007 2:20 pm

Re: getting rid of empty spans

Post by chrisklein »

I know, I know, the replace function works on several files. But still you have to do it manually! There is no automatic removal of empty opening and closing span tags.
RamonS
Senior Propellus Maximus
Posts: 4293
Joined: Thu Feb 02, 2006 9:29 am
Location: The Electric City

Re: getting rid of empty spans

Post by RamonS »

Sure there is, you search for the tags in the source files. You could also use some other batch find and replace tool, there are several.
doc_guy
Propellus Maximus
Posts: 1979
Joined: Tue Nov 28, 2006 11:18 am
Location: Crossroads of the West
Contact:

Re: getting rid of empty spans

Post by doc_guy »

I'm going to agree with chrisklein here, David. Sure you can search for <span> but, as you said, that only solves half your problems. If you search for <span> and replace it with nothing, then you're going to have a bunch of invalid topics that don't open because the XML isn't well-formed. If you search for </span></span> and replace it with </span>, then you are potentially going to remove legitimate versions of the double closing tag, and again end up with topics that won't open because they aren't well-formed.

The argument here isn't that Flare doesn't have find/replace or find in files. It clearly has that. But in this case, find/replace doesn't help because you can't batch find the files you're looking for with a normal search expression.

What you are going to want to do is to use a regular expression search. I'm not a reg-ex person; I think I've only tried once. But somebody who knows reg-ex will be able to create a simple regular expression that will match <span> any amount of text </span>. I think that will work for you. But you will want to back up your project before you do it to ensure you don't totally destroy the source files with a project-wide reg-ex replacement search, because that has the potential to get nasty very quickly.
Paul Pehrson
My Blog

Image
RamonS
Senior Propellus Maximus
Posts: 4293
Joined: Thu Feb 02, 2006 9:29 am
Location: The Electric City

Re: getting rid of empty spans

Post by RamonS »

I didn't claim anything else. As I mentioned in my earlier posts this is worth a try, I didn't claim that it the best way to do it. I also just noticed that I forgot to add the "/" for the closing span tags. It must be this:

You could try and see if searching for "</span></span>" and replacing it with "</span>" works out, but it may replace the closing tags of two legitimately intertwined spans with just one. I still think it is worth a try.

And further long the discussion was about if Flare can do a find and replace in source across all files in the project and it for sure can. Doc_guy, I am agreeing with what you point out and that is what I mentioned earlier, so I am a bit confused why you seem to claim that you disagree with me. RegEx may guide the search a bit more closely to the targets, but the time it takes to figure out which regex includes the desired cases and excludes the others the plain simple find&replace with manual confirmation is done. In any case your head will spin. Too bad it doesn't punish those who got the brilliant idea to use MS Word in the first place.
doc_guy
Propellus Maximus
Posts: 1979
Joined: Tue Nov 28, 2006 11:18 am
Location: Crossroads of the West
Contact:

Re: getting rid of empty spans

Post by doc_guy »

Your posts above seemed to me that you thought that chrisklein didn't understand Flare's find/replace capability. All I was saying was that chrisklein understands that Flare has find/replace but the standard find/replace won't do the search that chrisklein needs. You seemed to imply that it would. Yeah, you can do the search for the code that we both talked about, but that isn't automated. Any automated solution here is going to require some reg ex, in my opinion.
Paul Pehrson
My Blog

Image
KevinDAmery
Propellus Maximus
Posts: 1985
Joined: Tue Jan 23, 2007 8:18 am
Location: Darn, I knew I was around here somewhere...

Re: getting rid of empty spans

Post by KevinDAmery »

RamonS wrote:Too bad it doesn't punish those who got the brilliant idea to use MS Word in the first place.
Now now, David - haven't they been punished enough already? :mrgreen:
Until next time....
Image
Kevin Amery
Certified MAD for Flare
Post Reply