在RTE中保留空格,以保留pre和code标签 [英] Keep whitespaces in RTE for pre and code tags

查看:144
本文介绍了在RTE中保留空格,以保留pre和code标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过<pre>和/或<code>标签显示代码,效果很好.空格会在第一次保存时保存,并在前端正确显示.但是,当在后端重新加载内容时,编辑器将显示没有附加空格的代码.再次保存将删除整个代码格式.

我认为对此有一些设置,但是直到现在我什么都找不到.有任何提示吗?

为了突出显示代码,我使用了GeshiLibvjrtecodesnippets扩展名.

对不起,错过了配置.涉及到基本的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>标签工作正常.空格 在正文文本字段中存储为&nbsp;,因此保留 保存并重新打开时.
  • 您是否尝试过删除行
    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 vjrtecodesnippetsextensions.

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 &nbsp; 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 by vjrtecodesnippets. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆