Skip to main content
Tweeted twitter.com/#!/StackTridion/status/329880263251341312
edited tags
Link
added 3 characters in body
Source Link

We have an issue where our HTML/CSS requires RTF content to be wrapped in <p> tags in order for some design elements to work correctly.

We had some code which added these in if the string did not start with <p however this is too naive an implementation because it is possible for our editors to add <h2> and other block level elements to these RTFs (wrapping those in <p> tags is invalid markup and most browsers will autoclose to create this <p></p><h2>test</h2>test<p></p>).

Given this:

<h2>test</h2>
test

I want this:

<h2>test</h2>
<p>test</p>

I am struggling to think of an approach to solve this.

Would it be best to use HtmlTidy or similar to parse and "fix" the document? Or can this be achieved with filtering XSLT to add in any missing <p> tags around the inline text?

I guess a final alternative would be to change the schema to lock down the design.

We have an issue where our HTML/CSS requires RTF content to be wrapped in <p> tags in order for some design elements to work correctly.

We had some code which added these in if the string did not start with <p however this is too naive an implementation because it is possible for our editors to add <h2> and other block level elements to these RTFs (wrapping those in <p> tags is invalid markup and most browsers will autoclose create this <p></p><h2>test</h2>test<p></p>).

Given this:

<h2>test</h2>
test

I want this:

<h2>test</h2>
<p>test</p>

I am struggling to think of an approach to solve this.

Would it be best to use HtmlTidy or similar to parse and "fix" the document? Or can this be achieved with filtering XSLT to add in any missing <p> tags around the inline text?

I guess a final alternative would be to change the schema to lock down the design.

We have an issue where our HTML/CSS requires RTF content to be wrapped in <p> tags in order for some design elements to work correctly.

We had some code which added these in if the string did not start with <p however this is too naive an implementation because it is possible for our editors to add <h2> and other block level elements to these RTFs (wrapping those in <p> tags is invalid markup and most browsers will autoclose to create this <p></p><h2>test</h2>test<p></p>).

Given this:

<h2>test</h2>
test

I want this:

<h2>test</h2>
<p>test</p>

I am struggling to think of an approach to solve this.

Would it be best to use HtmlTidy or similar to parse and "fix" the document? Or can this be achieved with filtering XSLT to add in any missing <p> tags around the inline text?

I guess a final alternative would be to change the schema to lock down the design.

added 2 characters in body
Source Link

We have an issue where our HTML/CSS requires RTF content to be wrapped in <p> tags in order for some design elements to work correctly.

We had some code which added these in if the string did not start with <p however this is too naive an implementation because it is possible for our editors to add <h2> and other block level elements to these RTFs (wrapping those in <p> tags is invalid markup and most browsers will autoclose create this <p></p><h2>test</h2>test<p></p>).

Given this:

<h2>test</h2>
test

I want this:

<h2>test</h2>
<p>test</p>

I am struggling to think of an approach to solve this.

Would it be best to use HtmlTidy or similar to parse and fix"fix" the document? Or can this be achieved with filtering XSLT to add in any missing <p> tags around the inline text?

I guess a final alternative would be to change the schema to lock down the design.

We have an issue where our HTML/CSS requires RTF content to be wrapped in <p> tags in order for some design elements to work correctly.

We had some code which added these in if the string did not start with <p however this is too naive an implementation because it is possible for our editors to add <h2> and other block level elements to these RTFs.

I am struggling to think of an approach to solve this.

Would it be best to use HtmlTidy or similar to parse and fix the document? Or can this be achieved with filtering XSLT to add in any missing <p> tags around the inline text?

I guess a final alternative would be to change the schema to lock down the design.

We have an issue where our HTML/CSS requires RTF content to be wrapped in <p> tags in order for some design elements to work correctly.

We had some code which added these in if the string did not start with <p however this is too naive an implementation because it is possible for our editors to add <h2> and other block level elements to these RTFs (wrapping those in <p> tags is invalid markup and most browsers will autoclose create this <p></p><h2>test</h2>test<p></p>).

Given this:

<h2>test</h2>
test

I want this:

<h2>test</h2>
<p>test</p>

I am struggling to think of an approach to solve this.

Would it be best to use HtmlTidy or similar to parse and "fix" the document? Or can this be achieved with filtering XSLT to add in any missing <p> tags around the inline text?

I guess a final alternative would be to change the schema to lock down the design.

Source Link
Loading