Typo3: How to remove empty paragraphs on page

idleberg picture idleberg · Dec 19, 2013 · Viewed 8.2k times · Source

I'm using Typo3 v6.1 to create a standard page of the type “text”. In the view, Typo3 adds four empty paragraphs before and after the content created on the Rich Text Editor.

<p class="bodytext">&nbsp;</p>
<p class="bodytext">    <!--  CONTENT ELEMENT, uid:17/text [begin] --></p>
<p class="bodytext">        <a id="c17"></a></p>
<p class="bodytext">        <!--  Text: [begin] --></p>    

<p class="bodytext">The actual text added using the Rich Text Editor</p>    

<p class="bodytext">        <!--  Text: [end] --></p>
<p class="bodytext">&nbsp;</p>
<p class="bodytext">    <!--  CONTENT ELEMENT, uid:17/text [end] --></p>
<p class="bodytext">&nbsp;</p>  

It goes without saying, that I'd like to get rid off this clutter, especially since the &nbsp; are breaking the layout.

Answer

maholtz picture maholtz · Dec 19, 2013

There is a parseFunc < lib.parseFunc_RTE at the wrong place.

Looks like you have something like

page.10 = CONTENT
page.10.stdWrap.parseFunc < lib.parseFunc_RTE

Which would mean: render the content, and after that parse this content with lib.parseFunc_RTE. The code which activates the wrapping is

lib.parseFunc_RTE.nonTypoTagStdWrap.encapsLines.wrapNonWrappedLines = <p>|</p>

Removing would not solve the issue here, because the cause is, that lib.parseFunc_RTE is processed on the whole content element and not only on bodytext where it should be defined.

Have a look in your TypoScript or add it to your question.

for testing purpose:

Create a new Site on top level, and add only basic TypoScript (add css_styled_content template; Check clear setup and constants)

page = PAGE
page.10 < styles.content.get

Check that output, the content should not wrapped into p class="bodytext" anymore.

Update:

Using {content} where {content} is filled via styles.content.get f.e. the parseFunc is executed twice. styles.content.get executeds the parseFunc, so it can be outputted to the browser. But f:format.html executed lib.parseFunc too. So, that is, why your content is parsed twice.

# in this case, f:format.html does not need to execute the parseFunc again
<f:format.html  parseFuncTSPath="">{content}</f:format.html>

Use lib.parseFunc_RTE if you have an RTE field, use lib.parseFunc if you do not expect HTML-Code in the field (f.e. header).