Easy way to re-associate a paragraph with a new tag

This forum is for all Flare issues related to styles, stylesheets and XML.
Post Reply
fchan
Propeller Head
Posts: 47
Joined: Fri Aug 31, 2012 11:41 am

Easy way to re-associate a paragraph with a new tag

Post by fchan »

Sometimes you can't anticipate what styles you want to use for various paragraphs. What is the easiest way to change paragraph-tag association? Here's an example:

When I start writing a document from scratch, I don't want to think about style. Let's say I have to create a nested list, I use the easiest method, which is to use the default list styles provided in the menu and use indentation to indicate how the list items should be nested. The resulting code looks like this:
<ul>
<li>This is the first item of the list. </li>
<li>The following is a second-level bulleted item:<ul style="list-style-type: circle;"><li>This is a second-level bulleted list item.</li></ul>
</ul>

After I'm done writing, I want to make the list look pretty by embedding an image as a bullet marker ONLY for the second-level list items. Of course I can edit the code by hand for each <li> paragraph that is nested at the second level, but how do I do it easily for a large number of paragraphs? I can run a script to search and replace, but I don't know how to restrict the replacement to ONLY the <li> paragraphs at the second level of the list.

If I had the foresight, I could have created a style for the second level list item (e.g., li.secondlevel), which would allow me to change its definition easily later on. So I'm asking what I should do if I have not defined such a tag to begin with. Thanks!
nickatwork
Sr. Propeller Head
Posts: 457
Joined: Thu Sep 16, 2010 6:31 am
Location: London

Re: Easy way to re-associate a paragraph with a new tag

Post by nickatwork »

Couldn't you just run a find/replace on :<ul style="list-style-type: circle;"><li>
and replace it with <ul style="list-style-type: circle;"><li.secondlevel>

This is the <li> tag that you're talking about right? if need be, you could use a regular expression to hihglight just that <li> tag.
kwag_myers
Propellus Maximus
Posts: 810
Joined: Wed Jul 25, 2012 11:36 am
Location: Ann Arbor, MI

Re: Easy way to re-associate a paragraph with a new tag

Post by kwag_myers »

nickatwork wrote:Couldn't you just run a find/replace on :<ul style="list-style-type: circle;"><li>
and replace it with <ul style="list-style-type: circle;"><li.secondlevel>

This is the <li> tag that you're talking about right? if need be, you could use a regular expression to hihglight just that <li> tag.
I agree, the find/replace feature lets you use syntax and you can run the entire project or just one topic. I think that's the easy way out. However, if you have other nested lists with the same style, you'll have to go through one instance at a time (Find Next).
"I'm tryin' to think, but nothin' happens!" - Curly Joe Howard
fchan
Propeller Head
Posts: 47
Joined: Fri Aug 31, 2012 11:41 am

Re: Easy way to re-associate a paragraph with a new tag

Post by fchan »

Thanks for the response. Yes, I think I can do a find and replace globally. But as kwag_myers mentioned, the string being replaced might not be unique. If a third level list item is also using the circle as the bullet marker, I don't want to replace that. I was hoping that there's a way to indicate that "I want to replace the list format ONLY if it's at the second level."
nickatwork
Sr. Propeller Head
Posts: 457
Joined: Thu Sep 16, 2010 6:31 am
Location: London

Re: Easy way to re-associate a paragraph with a new tag

Post by nickatwork »

Post a section of your code that has multiple list levels, if you only want to replace the 2nd level then we can probably match that using a regular expression. Depends what your code looks like. Post it below and I'll check it out.
kwag_myers
Propellus Maximus
Posts: 810
Joined: Wed Jul 25, 2012 11:36 am
Location: Ann Arbor, MI

Re: Easy way to re-associate a paragraph with a new tag

Post by kwag_myers »

fchan wrote:Thanks for the response. Yes, I think I can do a find and replace globally. But as kwag_myers mentioned, the string being replaced might not be unique. If a third level list item is also using the circle as the bullet marker, I don't want to replace that. I was hoping that there's a way to indicate that "I want to replace the list format ONLY if it's at the second level."
Unfortunately, I can't think of an easy way to do this. If there is no distinction between the second and third level lists you're in a tough spot. The thing to remember with style sheets is you always want to make each format/font variation unique, even if you don't think it's significant at the time. But that doesn't help us with this dilemma.

If you only have a few third level lists, you could look through your output for them (they should be easier to spot in the output) and tag them in Flare as you find them.

The only other way I can come up with is to systematically go through the project using Find Next and add a class to your second level lists. I realize you're dealing with a large project, but this should be a one-time thing.

If you're not familiar with Flare's Find and Replace here's how it works: In the Options section of the Find and Replace container, set the Find in menu to (whole project) and select the Find in source code check box.

edit: Actually, with (whole project) you have to use Start button instead of Find Next.
Last edited by kwag_myers on Fri Sep 07, 2012 4:59 am, edited 1 time in total.
"I'm tryin' to think, but nothin' happens!" - Curly Joe Howard
i-tietz
Propellus Maximus
Posts: 1219
Joined: Wed Oct 24, 2007 4:13 am
Location: Fürth, Germany

Re: Easy way to re-associate a paragraph with a new tag

Post by i-tietz »

Two possibilities:
1.
a. Generate a class for the ul tag, let's say"circle" or "reddot"
b. Apply the styles that you wish that class to have, e.g. ul.reddot { list-style-image: url('../Images/reddot.png'); }
c. Assign that class to all the lists you want to have that red dot

2. If ALL the unordered lists (= ul) on the second level inside another ul are supposed to look that way:
a. Generate a complex selector ul ul
b. Apply the styles that you wish that "class" to have, e.g. ul ul { list-style-image: url('../Images/reddot.png'); }
Last edited by i-tietz on Fri Sep 07, 2012 1:46 am, edited 1 time in total.
Inge____________________________
"I need input! - Have you got input?"
NorthEast
Master Propellus Maximus
Posts: 6426
Joined: Mon Mar 05, 2007 8:33 am

Re: Easy way to re-associate a paragraph with a new tag

Post by NorthEast »

As i-tietz mentioned, you can use a complex selector to automatically format your list levels; it's discussed in detail here http://forums.madcapsoftware.com/viewto ... =12&t=4983.
fchan
Propeller Head
Posts: 47
Joined: Fri Aug 31, 2012 11:41 am

Re: Easy way to re-associate a paragraph with a new tag

Post by fchan »

Thanks for the suggestions. They are helpful! (If there are other ways, please post them as well.)
Post Reply