Cells filled with P tags in imported Word table

This forum is for all Flare issues related to importing files or projects.
Post Reply
oremphelyn
Jr. Propeller Head
Posts: 8
Joined: Tue Nov 06, 2018 4:44 pm

Cells filled with P tags in imported Word table

Post by oremphelyn »

Upon importing a Word document, every table cell is lined with unneeded P tags.

In Word, before importing the document to Flare, I assign the "Normal" style to all table text and verify that no inline formatting is applied to it. The content in the table cells are as plain vanilla as you can get.

In Flare, when preparing to import the Word file, I choose to carry over as few Word-specific styles as possible, mapping only a few critical ones like headings and body tags. On the Stylesheet tab, I choose "Don't preserve MS Word Styles" and I make sure "Convert inline formatting to CSS styles" is de-selected.

Yet, upon conversion Every. Single. Cell. of Every. Single. Table is lined with P tags, as shown below.

Code: Select all

<tr>
	<td>
		<p>Short Circuit Current Rating</p>
	</td>
	<td>
		<p>-30 to +70<span style="font-family: Symbol;">°</span> C</p>
	</td>
	<td>
		 <p>Over Voltage Category</p>
	</td>
	<td>
		<p>0 to +40<span style="font-family: Symbol;">°</span> C</p>
	</td>
</tr>
This is completely unnecessary. It requires extra work editing the CSS declaration for every style used in a table to be sure the P tag within a table is ignored, or to manually remove all instances of P within TH and TD. The hundreds of instances of P tags and the required additional multiple declarations within the CSS file all contribute bloat to the entire project.

Code: Select all

<tr class="TableStyle-OpenTable-NoRules-Body-Body1">
	<td class="TableStyle-OpenTable-NoRules-BodyE-Column1-Body1">
		<p>Short Circuit Current Rating</p>
	</td>
	<td class="TableStyle-OpenTable-NoRules-BodyE-Column1-Body1">
		<p>-30 to +70<span style="font-family: Symbol;">°</span> C</p>
	</td>
	<td class="TableStyle-OpenTable-NoRules-BodyE-Column1-Body1">
		<p>Over Voltage Category</p>
	</td>
	<td class="TableStyle-OpenTable-NoRules-BodyD-Column1-Body1">
		<p>0 to +40<span style="font-family: Symbol;">°</span> C</p>
	</td>
</tr>
The unneeded P tags also cloud my view when I sometimes need to work using the Text Editor (code) view.

Has anyone found a way to prevent Flare from spawning P with TH or TD upon import?

TIA ~ Brian
Curlyshell
Propeller Head
Posts: 65
Joined: Fri Mar 01, 2019 9:14 am

Re: Cells filled with P tags in imported Word table

Post by Curlyshell »

I really, really, really, really wish someone would answer this question.
"I'm a technical writer, not a developer," she said...
SteveS
Senior Propellus Maximus
Posts: 2087
Joined: Tue Mar 07, 2006 5:06 pm
Location: Adelaide, far side of the world ( 34°56'0.78\"S 138°46'44.28\"E).
Contact:

Re: Cells filled with P tags in imported Word table

Post by SteveS »

Just a thought...

Is there a return at the end of the cell's content in Word?
Image
Steve
Life's too short for bad coffee, bad chocolate, and bad red wine.
ChoccieMuffin
Senior Propellus Maximus
Posts: 2630
Joined: Wed Apr 14, 2010 8:01 am
Location: Surrey, UK

Re: Cells filled with P tags in imported Word table

Post by ChoccieMuffin »

No direct solution for you about how insanely ugly the resulting HTM is from a Word input, but you could possibly add a complex selector to your stylesheet so that td p is the same as td.
Started as a newbie with Flare 6.1, now using Flare 2023.
Report bugs at http://www.madcapsoftware.com/bugs/submit.aspx.
Request features at https://www.madcapsoftware.com/feedback ... quest.aspx
Curlyshell
Propeller Head
Posts: 65
Joined: Fri Mar 01, 2019 9:14 am

Re: Cells filled with P tags in imported Word table

Post by Curlyshell »

SteveS wrote:Just a thought...

Is there a return at the end of the cell's content in Word?
Good question, but no—I did check that. Thanks for thinking of it.

I'm going to try @ChoccieMuffin's idea....
"I'm a technical writer, not a developer," she said...
doc_guy
Propellus Maximus
Posts: 1979
Joined: Tue Nov 28, 2006 11:18 am
Location: Crossroads of the West
Contact:

Re: Cells filled with P tags in imported Word table

Post by doc_guy »

We specifically tell Flare to create paragraph tags in our tables when the table is created.

Image

We want this because we want table cells with multiple paragraphs or images to have the same spacing as table cells with a single paragraph.

And yes, we use a complex selector for P's in a TD, so the style is just right.

So, in my opinion, this is a feature, not a bug. But I agree that not everybody will see it this way, and I believe it would be reasonable to give users the option when they import Word files.
Paul Pehrson
My Blog

Image
Curlyshell
Propeller Head
Posts: 65
Joined: Fri Mar 01, 2019 9:14 am

Re: Cells filled with P tags in imported Word table

Post by Curlyshell »

Thanks! I figured out how to activate that box (create a row or column and click it), and I changed the selector from <p> to none; but the <p> tag remains. I even went into the CSS file using Notepad++ and removed every P reference I could find, but the <p> tags remain in my output. Any suggestions?
"I'm a technical writer, not a developer," she said...
doc_guy
Propellus Maximus
Posts: 1979
Joined: Tue Nov 28, 2006 11:18 am
Location: Crossroads of the West
Contact:

Re: Cells filled with P tags in imported Word table

Post by doc_guy »

Changing the CSS won't affect what elements are in your source topics. It will just affect how they are styled.

If you can, I'd revert the changes you made to your CSS. If you removed every instance of <p> style that you could find, you will have affected the style of all paragraphs in all situations. I don't think that is what you are trying to do.

The only way to remove that I'm aware of would be a find-and-replace. You'd want to use a regular expression to catch <p> tags that are inside <td> tags and remove the open <p> tag and leave the content alone and remove the closing </p> tag. I am not familiar enough with regular expressions to tell you how this would be accomplished, but this is the path that you'd want to go down.

I'd make sure you have a backup of your project before you do this, because find and replace in the code, *especially* with regular expressions can lead to unintended consequences.

Your other option is to just live with the <p> tags in tables. They are actually useful if you need multiple paragraphs or images or lists or whatever in your table cells. You can style them by adding a complex selector in your style sheet like this:

Code: Select all

td p {
    font-size:1em;
}
That will only affect <p> elements that are the child of <td> elements.
Paul Pehrson
My Blog

Image
doc_guy
Propellus Maximus
Posts: 1979
Joined: Tue Nov 28, 2006 11:18 am
Location: Crossroads of the West
Contact:

Re: Cells filled with P tags in imported Word table

Post by doc_guy »

Daniel Ferguson just showed me a way to remove <p> tags on a table-by table basis:

1. In the structure bar, click the table element to select the entire table.
2. In the Table tab (on the Ribbon), click Cell Content Style.
3. In the pop-up window, select "None."

The <p> tags are removed, as long as there was only one paragraph in the cell. If there are multiple paragraphs in the cell, you're out of luck.

You can create a macro to simplify this process across multiple tables, so you'd just click the table tag, and then press your macro key combination to do the rest.

Again, this is courtesy of Daniel Ferguson of SmartOutput.com. He's a genius, really.
Paul Pehrson
My Blog

Image
joel7
Propeller Head
Posts: 16
Joined: Fri Mar 20, 2015 9:46 am

Re: Cells filled with P tags in imported Word table

Post by joel7 »

I'd also note for any future readers that the Kaizen plugin can do this efficiently.
Curlyshell
Propeller Head
Posts: 65
Joined: Fri Mar 01, 2019 9:14 am

Re: Cells filled with P tags in imported Word table

Post by Curlyshell »

In the years since I last visited this thread, I've learned to be OK with the <p> tags by embracing @doc_guy 's solution. It never hurts to have a style for <p> tags within tables, since there's always a chance you'll need multiple paragraphs in a table. So I styled it the way I wanted and no more need for search-and-destroy.

But since we're talking about search-and-destroy: The other thing I learned to love (but have barely explored) is the "Find Elements" tab in Find and Replace. After much time spent learning regular expressions, I could have saved piles of time with this tab. I'll still need regular expressions for some things—am glad I learned them!—but this tab is amazing.
"I'm a technical writer, not a developer," she said...
Post Reply