Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
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
Solved! Go to Solution.
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
Insert cursor between the p tags and press the delete markup button in the toolbar or press CTRL + SHIFT + X.
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
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;
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
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
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
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
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
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
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
Clay, just looking at the other script the word function does not show up in it. So I would expect it is a sequence of commands.
Thanks for the help
Bryon