Keep whitespaces in RTE for pre and code tags


I want to display code through <pre> and/or tags, which works fine. White spaces are saved on first save and displayed properly in the front-end. However, when reloading the content in the backend, the editor shows the code without the additional whitespaces. Saving again drops the whole code formatting.

I assume there is some setting for this but I couldn't find anything until now. Any hints on this?

For the code highlighting, I am using the GeshiLib and vjrtecodesnippetsextensions.


Sorry, missed the configuration. There is the basic rtehtmlarea involved, currently v4.7.5, there is no TCA specific change since it is a standard bodytext field from TYPO3's standard <em>Text content element</em> (displayed through css_styled_content).

PageTS for the RTE looks like the following:

RTE.default.hidePStyleItems := removeFromList(pre) RTE.default.proc { allowTags := addToList(pre) entryHTMLparser_db.allowTags < RTE.default.proc.allowTags overruleMode = tx_vjrtecodesnippets,ts_css,cleanenc allowTags := addToList(code) allowTagsOutside := addToList(code) entryHTMLparser_db { allowTags < RTE.default.proc.allowTags allowTagsOutside < RTE.default.proc.allowTagsOutside } HTMLparser_rte { allowTags < RTE.default.proc.allowTags allowTagsOutside < RTE.default.proc.allowTagsOutside } }

<strong>Edit2:</strong> We've published the TYPO3 extension news_blog which does exactly this.


I wanted to write a comment, but a short answer with sophisticated guesses might be just as good:

<ul><li>I checked at my own site, the tag works fine. Whitespaces are stored as &nbsp; in the bodytext field, therefore preserved when saved and re-opened. </li> <li>Have you tried deleting the line<br />RTE.default.hidePStyleItems := removeFromList(pre)?</li> <li>According to the <a href="http://typo3.org/extension-manuals/vjrtecodesnippets/0.0.4/view/1/2/" rel="nofollow">manual</a>, only tags are supported by vjrtecodesnippets. Do you really need <em>both</em> tags for syntax highlighting? </li> <li>Also, have you tried changing your PageTS like follows to enable <pre>?:</li> </ul>


RTE.default.proc { allowTagsOutside := addToList(code,pre) }

<strong>EDIT:</strong><br /> I found a related <a href="http://snipplr.com/view/9197/" rel="nofollow">TypoScript snippet</a>, which might be noteworthy for your case. Please try making the following adjustments:

In the Template SETUP section:

lib.parseFunc.allowTags := addToList(code,pre) lib.parseFunc_RTE.allowTags := addToList(code,pre)

In the PAGE TSconfig:

RTE.default.proc { allowTags := addToList(code,pre) allowTagsOutside := addToList(code,pre) overruleMode = tx_vjrtecodesnippets,ts_css,cleanenc // CONTENT TO DATABASE HTMLparser_rte { allowTags < RTE.default.proc.allowTags allowTagsOutside < RTE.default.proc.allowTagsOutside } // Entry HTML parser entryHTMLparser_db { allowTags < RTE.default.proc.allowTags allowTagsOutside < RTE.default.proc.allowTagsOutside } }


this works on typo3 7.4

RTE.default.proc { allowTags := addToList(pre) HTMLparser_rte { allowTags < RTE.default.proc.allowTags } entryHTMLparser_db { allowTags < RTE.default.proc.allowTags } }

for sure you can also add more tag names seperated with " , "

for more settings to your RTE in typoscript check out. <a href="https://docs.typo3.org/typo3cms/CoreApiReference/6.2/Rte/Transformations/Tsconfig/Index.html" rel="nofollow">https://docs.typo3.org/typo3cms/CoreApiReference/6.2/Rte/Transformations/Tsconfig/Index.html</a>


  • TYPO3 RTE: Saving mathematical/greek symbols doesn't work
  • How to set parent view's height based on subview's height
  • Google scripts docs italicize appended text
  • Set 'From' email address in Lotus Notes when sending via VBA
  • PIDinRootline for TCA mm relation for 'foreign_table_where'
  • How can I add an action to a TYPO3 frontend plugin?
  • Conditional if a post in tt_news belongs to certain category
  • C: Incompatible pointer type initializing
  • why xml file does not aligned properly after append the string in beginning and end of the file usin
  • How to define custom class, title, and target in Link Browser for content elements and the new rte_c
  • How can I sort a a table with VBA with given text condition?
  • How to use carriage return with multiple line?
  • How to Cache Real-time Data?
  • Abort upload large uploads after reading headers
  • JSON response opens as a file, but I can't access it with JavaScript
  • Play WS (2.2.1): post/put large request
  • Set the selected item in dropdownlist in MVC3
  • Python CGI os.system causing malformed header
  • DomPDF {PAGE_NUM} not on first page
  • Control modification in presentation layer
  • Retrieving value from sql ExecuteScalar()
  • AES padding and writing the ciphertext to a disk file
  • How to convert from System.Drawing.Color to Excel.ColorFormat in C#? Change comment color
  • Why doesn't :active or :focus work on text links in webkit? (safari & chrome)
  • Validaiting emails with Net.Mail MailAddress
  • MySQL WHERE-condition in procedure ignored
  • Weird JavaScript statement, what does it mean?
  • Adding custom controls to a full screen movie
  • Web-crawler for facebook in python
  • Calling of Constructors in a Java
  • Confusion with PayPal's monthly billing cycle
  • Traverse Array and Display in markup
  • Transpose CSV data with awk (pivot transformation)
  • KeystoneJS: Relationships in Admin UI not updating
  • trying to dynamically update Highchart column chart but series undefined
  • Why can't I rebase on to an ancestor of source changesets if on a different branch?
  • Hits per day in Google Big Query
  • Checking variable from a different class in C#
  • Django query for large number of relationships
  • java string with new operator and a literal