Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

In the SDL Tridion 2011 content management system, when editing a component in a rich text field (RTF) I noticed pressing enter results in different HTML tags in the source.

I think it's based on browser since I get <div> with Chrome. How do I make sure I get <p> tags in all browsers?

Update: SDL Tridion 2011 SP1 has the following in the default XSLT schema rich text filter, which appears to fix the scenario of pressing enter when editing regular Body Text or paragraphs. I still have the issue when pressing enter after a heading, which comes out as a div in Chrome.

<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(., &apos; &apos;, &apos;&apos;)) = &apos;&apos;     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(., &apos; &apos;, &apos;&apos;)) = &apos;&apos;        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>

Updated question then is:

How do I make sure I get <p> tags in all browsers, even when pressing enter after a heading?

share|improve this question
add comment

migrated from superuser.com May 9 '12 at 10:25

This question came from our site for computer enthusiasts and power users.

2 Answers

The problem is not new, and is a general problem with using contenteditable.
http://stackoverflow.com/questions/2735672/how-to-change-behavior-of-contenteditable-blocks-after-on-enter-pressed-in-vario

Telerik as brought out a solution, where you can specify which behavior you want, something I suggest SDL also do. http://www.telerik.com/help/aspnet-ajax/editor-using-newlinebr-property.html

But it appear it just did not get attention yet. The bigger question is, when does SDL start make use of HTML 5...

share|improve this answer
    
Thanks, @Hendrik. I see SP1 fixed some of this with an XSLT filter change, but not returns after headings. –  Alvin Reyes May 8 '12 at 3:50
add comment

We have exactly the same issue - this is based on specific browser behavior. I have found Fire Fox, IE and Chrome to all give different results. If memory serves well:

  • IE gives <p> tags
  • Fire Fox gives a double <br/>
  • Chrome uses a <div/> tag

I have a ticket filed with Customer Support about this, but as of now, I still don't have a solution. So we paste content into the field at the moment rather than actually editing in it otherwise it messes up our XHTML standards and our CSS does not work correctly.

share|improve this answer
    
I don't remember the version I was on (definitely before SP1, but either GA or Hotfix Rollup) and I had the same behavior. I have the following version on my test machine and get <p> tags with Chrome in RTF by pressing enter now. Content Manager Explorer - Build 6.1.0.55920 Content Manager - Build 6.1.0.996 Update Version - SP1 However, after changing text to a heading level, pressing return gives me a new "Generic container (div)" or <div>. I'd expect a paragraph, similar to how Word does <p> by default. –  Alvin Reyes Apr 25 '12 at 19:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.