Feature #20555

New parseFunc setting

Added by tyler kraft over 10 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
TypoScript
Target version:
Start date:
2009-06-03
Due date:
% Done:

100%

PHP Version:
Tags:
Complexity:
Sprint Focus:

Description

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 --
class user_parseFunc {
function stripEmptyTags($content,$conf) {
$tags = explode(',',$conf['tagList']);
$strip = array();
foreach ($tags as $k => $tag) {
$strip[] = '%<'.$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)


Related issues

Related to TYPO3 Core - Feature #16340: option to remove empty elements Closed 2006-07-12
Related to TYPO3 Core - Feature #39676: Delete empty paragraphs Closed 2012-08-10
Related to TYPO3 Core - Bug #17750: Empty paragraph-tags with attributes are not editable Closed 2007-11-03

Associated revisions

Revision 03bd2256 (diff)
Added by Alexander Stehlik almost 5 years ago

[FEATURE] Allow stripping of empty tags in HtmlParser

Add a stripEmptyTags method to the HtmlParser
It can be enabled by TypoScript or TSConfig:

HTMLparser.stripEmptyTags = 1
HTMLparser.stripEmptyTags.tags = h2, h3
HTMLparser.stripEmptyTags.treatNonBreakingSpaceAsEmpty = 1

Resolves: #20555
Releases: master
Change-Id: I640486e9f32da6ac1eba05e3c38d15a0aba41055
Reviewed-on: http://review.typo3.org/16975
Reviewed-by: Frank Nägler <>
Tested-by: Frank Nägler <>
Reviewed-by: Anja Leichsenring <>
Tested-by: Anja Leichsenring <>

History

#1 Updated by tyler kraft over 10 years ago

Additionally this would be perfect if it would even strip out empty tagsets that even have attributes in the tag - eg <b class="blah"></b>

#2 Updated by Gerrit Code Review about 7 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/16975

#3 Updated by Gerrit Code Review about 7 years ago

Patch set 2 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/16975

#4 Updated by Gerrit Code Review about 7 years ago

Patch set 3 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/16975

#5 Updated by Gerrit Code Review about 7 years ago

Patch set 4 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/16975

#6 Updated by Gerrit Code Review over 6 years ago

Patch set 8 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16975

#7 Updated by Gerrit Code Review over 6 years ago

Patch set 9 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16975

#8 Updated by tyler kraft over 6 years ago

Hi
Forgive me if I'm mistaken but this seems to be being applied to the RTE html parser. While that is great it would also be very useful to be applied to the basic parsefunc that one could call from template TS. Will this be possible?

#9 Updated by Gerrit Code Review over 5 years ago

Patch set 10 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/16975

#10 Updated by Gerrit Code Review over 5 years ago

Patch set 11 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/16975

#11 Updated by Gerrit Code Review over 5 years ago

Patch set 12 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/16975

#12 Updated by Gerrit Code Review almost 5 years ago

Patch set 13 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/16975

#13 Updated by Gerrit Code Review almost 5 years ago

Patch set 16 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/16975

#14 Updated by Gerrit Code Review almost 5 years ago

Patch set 17 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/16975

#15 Updated by Gerrit Code Review almost 5 years ago

Patch set 18 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/16975

#16 Updated by Stephan Großberndt almost 5 years ago

  • Tracker changed from Bug to Feature
  • Description updated (diff)
  • Category set to TypoScript
  • Target version changed from 0 to next-patchlevel

#17 Updated by Alexander Stehlik almost 5 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

#18 Updated by Benni Mack about 1 year ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF