在RTE中保留空格,以保留pre和code标签 [英] Keep whitespaces in RTE for pre and code tags
问题描述
我想通过<pre>
和/或<code>
标签显示代码,效果很好.空格会在第一次保存时保存,并在前端正确显示.但是,当在后端重新加载内容时,编辑器将显示没有附加空格的代码.再次保存将删除整个代码格式.
我认为对此有一些设置,但是直到现在我什么都找不到.有任何提示吗?
为了突出显示代码,我使用了GeshiLib
和vjrtecodesnippets
扩展名.
对不起,错过了配置.涉及到基本的rtehtmlarea
,当前为v4.7.5,没有TCA特定的更改,因为它是TYPO3的标准文本内容元素(通过css_styled_content
显示)的标准正文文本字段.>
RTE的PageTS如下所示:
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 :我们已经发布了TYPO3扩展news_blog来完成此操作.
我想写评论,但简短的答案加上复杂的猜测可能同样好:
- 我在自己的网站上进行了检查,
<code>
标签工作正常.空格 在正文文本字段中存储为
,因此保留 保存并重新打开时. - 您是否尝试过删除行
RTE.default.hidePStyleItems := removeFromList(pre)
? - 根据手册,仅<
vjrtecodesnippets
支持c1>标记.您真的需要两个标签来突出显示语法吗? - 还,您是否尝试过如下更改PageTS来启用
<pre>
?:
-
RTE.default.proc {
allowTagsOutside := addToList(code,pre)
}
我找到了一个相关的 TypoScript片段,这可能对您的情况值得注意.请尝试进行以下调整:
在模板设置"部分:
lib.parseFunc.allowTags := addToList(code,pre)
lib.parseFunc_RTE.allowTags := addToList(code,pre)
在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
}
}
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.
I wanted to write a comment, but a short answer with sophisticated guesses might be just as good:
- I checked at my own site, the
<code>
tag works fine. Whitespaces are stored as
in the bodytext field, therefore preserved when saved and re-opened. - Have you tried deleting the line
RTE.default.hidePStyleItems := removeFromList(pre)
? - According to the manual, only
<code>
tags are supported byvjrtecodesnippets
. Do you really need both tags for syntax highlighting? - Also, have you tried changing your PageTS like follows to enable
<pre>
?:
-
RTE.default.proc {
allowTagsOutside := addToList(code,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:
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
}
}
这篇关于在RTE中保留空格,以保留pre和code标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!