cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Remove <P> element from a table

SOLVED
Level 11

Remove <P> element from a table

I have copy and pasted a table into editor and did not notice till the end that it had included a P element around each piece of text. Is there a way to remove all the P elements in my table and keep the text that is in them.

Bryon

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Remove <P> element from a table

Hi Bryon--

You could make this one step fairly easily, by adding a line to invoke the function at the end of the file, like this:

function remove_p_tags()
{
local oid = oid_first_tag()
local cnt
local i = 1

cnt = oid_find_children(oid, $arr, "p")
for ($i=1; $i<=$cnt; $i+=1)
{
if (oid_name(oid_parent($arr[$i])) == "entry")
{
goto_oid($arr[$i],-1)
dt
}
}
}

remove_p_tags();

That way, sourcing the file will both load the function definition and invoke it. I suspect that's how the other script was written; or possibly the other script didn't bother defining a function, it just contained a sequence of commands to be executed directly.

--C

11 REPLIES 11

Re: Remove <P> element from a table

Insert cursor between the p tags and press the delete markup button in the toolbar or press CTRL + SHIFT + X.

Re: Remove <P> element from a table

Thanks for the response, but I have alot of cells to fix, this would be a long way to the end. It would be quicker to reimport the table and make the other formating changes. I thought that someone outhere that is way more capabale than I had written a macro or something like that, that you could select the table and run it and would remove all the markup.

Bryon

Re: Remove <P> element from a table

I tried recording a macro to remove a p tag but I don't know who to have the macro delete all of the p tags. Does anyone know how to remove all of the p tags but leave the text in the table?

#FindTagAttribute;

find::find_tag('^(p)$', 2, 1, 4);

DeleteMarkup;

Re: Remove <P> element from a table

It is not clear as to how often you encounter this scenario or if you are looking for a long term solution; however, a fairly quick way to do this is to highlight the table element and then choose Edit Selection as XML Source from the Edit menu. In the Edit Selection as XML Source dialog, use Find/Replace to replace "<p>" and "</p>" with an empty string. When you close the Edit Selection as XML Source dialog, you'll be prompted to save your changes. The table will then refresh in Editor and the <p> tags will be removed.

Regards,

Phil Molstad

Re: Remove <P> element from a table

Thanks Phil this is the closest so far to what I was hoping for. We are new to editor and we have new people joining. We hav created a few tables that were not formating correctly and narrowed it down to issues with <P> elements in the table. I find it funny that I can select lots of cells in my table with data in them and choose insert markup and it will populate all the selected fields with the markup that I chose (as long as its allowed). Yet you cannot choose to remove markup from multiple cells, it will only remove it from the last cell selected. I am expecting this is a bug in the program. Thanks for all your help

Bryon

Highlighted

Re: Remove <P> element from a table

Bryon, I know it has been a while since this post was visited; however, I was recently requested to come up with a solution for this myself so here is an ACL function that should successfully remove the <p> element from your table cells in the current document. Source this function from Arbortext and execute it against the current document and it will walk through the document removing the <p> elements found inside any <entry> element.

function remove_p_tags()
{
local oid = oid_first_tag()
local cnt
local i = 1

cnt = oid_find_children(oid, $arr, "p")
for ($i=1; $i<=$cnt; $i+=1)
{
if (oid_name(oid_parent($arr[$i])) == "entry")
{
goto_oid($arr[$i],-1)
dt
}
}
}

Thanks,

Phil

Re: Remove <P> element from a table

I have copied the text you have supplied into a txt file and renamed it remove_p.acl. To use it what do I need to do. The other .acl script that Dmitry help me with I need to enter source remove_P.acl in the command window to use it. This one does nothing at the moment when I try to use it the same way. I have copied this new .acl file to the editor\packages folder. Is it cursor specfic that I need to be in the table, or have the table selected?

Thanks

Bryon

Re: Remove <P> element from a table

Hi Bryon--

Sourcing the file will load the function definition, but then you need to call the function it defines. So, after "source remove_P.acl", in the command window type "remove_p_tags()" and that should trigger the function and strip your table <p> elements out.

--Clay

Re: Remove <P> element from a table

Thanks clay that seems to work. Another question I would have is Dmitry created me an auto_index.acl file that adds the index element to whatever column my cursor is in. But it only needs one step why is this two?

Bryon