Project

General

Profile

Feature #20555

Updated by Stephan Großberndt about 9 years ago

I only say parseFunc as I'm not sure where this would best be incorporated - perhaps HTMLparser might be more appropriate. 

 Sometimes we end up with empty tag sets (eg: <b></b>) in the content; Peter Klein emailed the T3 english list about it 23/01/2008. Peter then wrote a small userFunc to strip these empty tags out that could possibly be easily added to parseFunc or HTMLparser functions. 

 From Peters posting: 

 -- cut Typoscript SETUP - cut -- 
 page.includeLibs.user_parseFunc = fileadmin/scripts/parseFunc.inc 

 lib.parseFunc.nonTypoTagUserFunc = user_parseFunc->stripEmptyTags 
 lib.parseFunc.nonTypoTagUserFunc.tagList = b,strong,i 
 lib.parseFunc_RTE.nonTypoTagUserFunc = user_parseFunc->stripEmptyTags 
 lib.parseFunc_RTE.nonTypoTagUserFunc.tagList = b,strong,i 

 -- cut Typoscript SETUP - cut -- 


 -- cut - File: fileadmin/scripts/parseFunc.inc - cut -- 
 <?php 
 class user_parseFunc { 
 function stripEmptyTags($content,$conf) { 
 $tags = explode(',',$conf['tagList']); 
 $strip = array(); 
 foreach ($tags as $k => $tag) { 
 $strip[] = '%<'.$tag.'></'.$tag.'>%si'; 
 } 
 return preg_replace($strip, '', $content); 
 } 
 } 
 ?> 
 -- cut - File: fileadmin/scripts/parseFunc.inc - cut -- 


 Perhaps this could become: 
 ...stripEmptyTags = 1 
 ...stripEmptyTags.tagList = b,i,strong 

 where stripEmptyTags = 1 strips out all empty tag sets, and the use of the sub property would then causes it to strip out only the listed tags instead? 

 With time it is becoming more and more important to have validator compliant html, this would be nice to see in 4.3 if it's possible. 

 (I've check TSref    for 4.2, and I've gone through the previous bugs and I can't see any similar posting or function so sorry if this is duplicate work) 





 





 (issue imported from #M11252)

Back