0

If you type some text (e.g. "hello") in a rich text format (RTF) area without pressing enter, a Component will save:

<body>hello</body>

If you press enter, however, the field will add wrapping markup (i.e. <p>).

<body><p>hello</p></body>

This question may solicit a few opinions, but I'm interested knowing:

  1. How do you ustually handle this difference (editor training, XSLT filter, TBB, template, ignore...)?
  2. Do your HTML designs tend to expect rich text to include certain tags in rich text format? For example, are paragraph tags and other block level element expected?

2 Answers 2

4

I strongly suspect there's no single answer here given this issue has been around for many years, so I'll post a few quick thoughts to keep the conversation going....

Adding the <p> tags in code

You'd need to be careful of making an assumption that all content should be in a <p> tag - what if the RTF is to present just a xx - you'd have to considerable design login in your templating I suspect ...

This is frought with challenges - the different formats of HTML are all but infinite (e.g. many readers may be considering we would only have

this test

or

<p>this test</p>

but consider parsing something less 'linear' such as

<p>this</p>&nbsp;<div>test</div> 

In addition - you're playing with the content behind the scenes which could make debugging from an editor perspective near impossible.

XSLT Filter

I'm going from memory here but the RTF snippet isn't an XML document but it's a fragment (and I suspect there's some backend manipulation to avoid the old browser difference behaviour we used to see) - I've not recent experience of trying this but recall it was a nightmare in the page!

XML Manipulation

If you put the snippet into your own XML DOM then you would be able to control what you do with the content and perhaps manage the content in a more controlled manner

Training

Training costs' the organisation although it moves the requirement from a technical challenge to someone else - seems nice but many organisations will fight back with putting such dependencies (HTML Knoweledge of any sort) on editorial staff. Despite this - it's the most frequently used approach I've seen. If this is just a case of training them on pressing enter after they've entered a single line RTF content perhaps this is more viable

Styling

Given the presentation of this is the issue (i.e. when this is published it may look rubbish without the correct <p> tags I wonder if it would be possible to have something added to the FormatAreaStyles.css to display to an editor that they've not yet created the text in a <p> tag (perhaps a red border around plain block text) - although this is labelled styling it would involve an awareness (read training) by the editors.

Extension

Could you code an extension that would simulate a forced 'enter' and then 'trim' on losing focus from any RTF field?

2
  • The browser differences at least for paragraphs were fixed by an updated XSLT filter (see my WebMasters question, back before TRex. Maybe training for design would be better than CMS editor training--basically that they could have these types of variations in rich text areas? I like the styling and extension ideas as well--which are more like nudges and hints rather than forcing a single approach. Jul 2, 2015 at 7:52
  • I think you've a very good point with training for design . To often the designers will proclaim 'I don't know what Tridion will allow'. It's always good to point them to standard RTF Plugins and point out these types of quirks ~ i.e. remove the 'Tridion does...' barrier ~. From here you can work with them and discuss how they may be able to manage the possible HTML variations (at the risk of a tiny bit of bloat in the CSS). Jul 2, 2015 at 8:10
1

we have used all the possible solution you mentioned except below

  • Editor Training - but some smart editors take care of it.

as per need of template we have tried various ways. but sometime one single solution does not works for all of your templates. so mix of c# tbb and html design work to accept p tags.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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