I want to display code through <pre>
and/or <code>
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 vjrtecodesnippets
extensions.
Edit:
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 Text content element (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
}
}
Edit2: We've published the TYPO3 extension news_blog which does exactly this.
this works on typo3 7.4
for sure you can also add more tag names seperated with " , "
for more settings to your RTE in typoscript check out. https://docs.typo3.org/typo3cms/CoreApiReference/6.2/Rte/Transformations/Tsconfig/Index.html
I wanted to write a comment, but a short answer with sophisticated guesses might be just as good:
<code>
tag works fine. Whitespaces are stored as
in the bodytext field, therefore preserved when saved and re-opened.RTE.default.hidePStyleItems := removeFromList(pre)
?<code>
tags are supported byvjrtecodesnippets
. Do you really need both tags for syntax highlighting?<pre>
?:-
EDIT:
I found a related TypoScript snippet, which might be noteworthy for your case. Please try making the following adjustments:
In the Template SETUP section:
In the PAGE TSconfig: