首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用SDL Tridion的不同浏览器中的段落标记?

使用SDL Tridion的不同浏览器中的段落标记?
EN

Webmasters Stack Exchange用户
提问于 2012-04-25 18:02:58
回答 2查看 365关注 0票数 7

在SDL 2011内容管理系统中,当编辑富文本字段(RTF)中的组件时,我注意到按enter键会导致源中不同的HTML标记。

我认为这是基于浏览器的,因为我有Chrome的<div>。如何确保在所有浏览器中获得<p>标记?

更新:SDLTridion2011 SP1在默认的XSLT富文本过滤器中有以下内容,它似乎修复了编辑常规正文文本或段落时按enter的场景。当按下标题后的enter键时,我仍然有问题,标题在Chrome中是作为div出现的。

代码语言:javascript
复制
<stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <output omit-xml-declaration="yes" method="xml" cdata-section-elements="script"></output>
    <template match="/ | node() | @*">
        <copy>
            <apply-templates select="node() | @*"></apply-templates>
        </copy>
    </template>
    <template match="*[      (self::br or self::p or self::div)     and      normalize-space(translate(., ' ', '')) = ''     and      not(@*)     and      not(processing-instruction())     and      not(comment())     and      not(*[not(self::br) or @* or * or node()])     and      not(following::node()[not(         (self::text() or self::br or self::p or self::div)        and         normalize-space(translate(., ' ', '')) = ''        and         not(@*)        and         not(processing-instruction())        and         not(comment())        and         not(*[not(self::br) or @* or * or node()])       )])     ]">
        <!-- ignore all paragraphs and line-breaks at the end that have nothing but (non-breaking) spaces and line breaks -->
    </template>
    <template match="br[parent::div and not(preceding-sibling::node()) and not(following-sibling::node())]">
        <!-- Chrome generates <div><br/></div>. Renders differently in different browsers. Replace it with a non-breaking space -->
        <text> </text>
    </template>
</stylesheet>

更新后的问题如下:

如何确保在所有浏览器中获得<p>标记,即使在标题后按enter?

EN

回答 2

Webmasters Stack Exchange用户

发布于 2012-05-05 18:28:56

这个问题不是新问题,是使用内容可编辑的一个普遍问题。

https://stackoverflow.com/questions/2735672/how-to-change-behavior-of-contenteditable-blocks-after-on-enter-pressed-in-vario

Telerik提出了一个解决方案,您可以指定您想要的行为,我建议SDL也这样做。http://www.telerik.com/help/aspnet-ajax/editor-using-newlinebr-property.html

但它似乎还没有引起注意。更大的问题是,SDL什么时候开始使用HTML 5.

票数 6
EN

Webmasters Stack Exchange用户

发布于 2012-04-25 18:11:15

我们有完全相同的问题-这是基于特定的浏览器行为。我发现Fire,IE和Chrome都给出了不同的结果。如果记忆正常的话:

  • IE给出<p>标签
  • Fire Fox提供双<br/>
  • Chrome使用<div/>标签

我有一张向客户支持提交的罚单,但到目前为止,我还没有一个解决方案。因此,我们现在将内容粘贴到字段中,而不是实际在其中进行编辑,否则会破坏我们的XHTML标准,并且我们的CSS无法正常工作。

票数 5
EN
页面原文内容由Webmasters Stack Exchange提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://webmasters.stackexchange.com/questions/29505

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档