removing p tags from within multiple table cells

Hi Everyone
Ive been working on an action which strips out lots of inserted code within a freeway table… such as inline styles etc that part is working fine but I also wanted to remove the paragraph tag from individual cells but I can’t work out how to remove them across all cells.
Here is the standard remove p tag which I am using which works fine within an individual cell
Does anyone have an idea how I can get it to work across all the cells

cheers for any pointers

  <item-action name="delete p tag within table cell" title="REMOVE: P Tag within Tables">
  <action-checkbox name="activate" title="Activate"/>
  <action-label name="separator" title="-"/>
  <action-label name="instructions" title="Remove the p tag within a table"/>
  <action-version version="1.1">
  Deletes the p TAG within a table cell. 
  </action-version>
  <action-javascript>
  function fwAfterEndHTML(){
  	if(!fwParameters['activate'].fwBoolValue) return false;
  	var myTarget = fwDocument.fwTags.fwFind('p',fwItem);
  		if(myTarget){
  			var myContents = myTarget.fwFindAllContent();
  			var myCont = myTarget.fwFindEnclosing();
  			var newDiv = myCont.fwAdd('',myTarget,true);
  			newDiv.fwMove(myContents);
  			myTarget.fwDelete();
  					}
  		return true
  	}
  	</action-javascript>
  </item-action>

actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Hi Max,
I don’t really have time to look at this in any detail at the moment but you should be able to do what you want by looking for all the P tags in the attached items and then iterating through these one at a time;

var myTargets = fwDocument.fwTags.fwFindAll('p',fwItem);
for (var a=0; a < myTargets.length; a++){
	var myTarget = myTargets[a];
	
	etc.

Regards,
Tim.

On 12 Feb 2015, at 14:45, max wrote:

var myTarget = fwDocument.fwTags.fwFind(‘p’,fwItem);
if(myTarget){


FreewayActions.com - Freeware and commercial Actions for Freeway Express & Pro - http://www.freewayactions.com


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Thanks tim I got it to work

cheers max


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Have a look at how I did this in SemanticTable: http://actionsforge.com/actions/semantictable

Walter

On Feb 12, 2015, at 9:45 AM, max email@hidden wrote:

Hi Everyone
Ive been working on an action which strips out lots of inserted code within a freeway table… such as inline styles etc that part is working fine but I also wanted to remove the paragraph tag from individual cells but I can’t work out how to remove them across all cells.
Here is the standard remove p tag which I am using which works fine within an individual cell
Does anyone have an idea how I can get it to work across all the cells

cheers for any pointers

 <item-action name="delete p tag within table cell" title="REMOVE: P Tag within Tables">
 <action-checkbox name="activate" title="Activate"/>
 <action-label name="separator" title="-"/>
 <action-label name="instructions" title="Remove the p tag within a table"/>
 <action-version version="1.1">
 Deletes the p TAG within a table cell. 
 </action-version>
 <action-javascript>
 function fwAfterEndHTML(){
 	if(!fwParameters['activate'].fwBoolValue) return false;
 	var myTarget = fwDocument.fwTags.fwFind('p',fwItem);
 		if(myTarget){
 			var myContents = myTarget.fwFindAllContent();
 			var myCont = myTarget.fwFindEnclosing();
 			var newDiv = myCont.fwAdd('',myTarget,true);
 			newDiv.fwMove(myContents);
 			myTarget.fwDelete();
 					}
 		return true
 	}
 	</action-javascript>
 </item-action>

actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

core blimey walter I just rebuilt all of those functions aaarrrrr
i didn’t even know you had already done it…
ohh well

thanks for posting the link to your action

max


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Hi Walter
Just been looking at yours and it certainly is concise and neat.
As I mentioned I have put together a set of actions which I needed (not realising you had already created half of them) for a mockup… and whilst I was doing that. I did ponder on the fact that one area where all these actions including mine seem to fall down on is in the state they leave the html structure. After all the moving and deleting of elements within the publishing cycle, the actual visual html layout really starts to resemble a right old dogs diner. Some time ago I did look into if an html cleanup was feasible but never got very far with it (jobs got in the way) Anyway at some point I would suggest it would be handy if softpress gave developers some easy way to clean up the html without using an external source.
Anyway its all food or thought
all the best max


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Yes, I have often hoped that there could be a last pass after all Actions have run where a “pretty-printer” could clean up the resulting picket-fence code (lots of gaps where tags were removed and re-shuffled). Naturally this doesn’t affect the More Efficient output, but it plays havoc with the More Readable, which should look like an OCD hand-coder gave it the treatment, in my NSHO.

Walter


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options