Jump to content

Recommended Posts

Hi,

 

i've got a problem with the HTML generated from IE with designMode on.

 

The internet explorer generates invalid html like this:

 

<P><STRONG> </P>
<P> </P>
<P> </P></STRONG>
<P> </P>
<P><STRONG> </P>
<P> </P>
<P> </P></STRONG>

 

or like this...

 

<P><STRONG><EM>Lorem ipsum...</P>
<P> </P></EM></STRONG>

 

I need to fix that HTML-Code on serverside to get valid html that should look like:

Example 1: ( or remove all STRONG tags )

<P><STRONG> </STRONG></P>
<P><STRONG> </STRONG></P>
<P><STRONG> </STRONG></P>
<P> </P>
<P><STRONG> </STRONG></P>
<P><STRONG> </STRONG></P>
<P><STRONG> </STRONG></P>

 

Example 2:

<P><STRONG><EM>Lorem ipsum...</EM></STRONG></P>
<P> </P>

 

I tried to create several RegExp to match this certain HTML. But my regular expressions failed or destroyed the html by too much recursion or greedy behavior.

 

I would be very thankful, if someone could help me. I just need to get valid html and keep the formatting on the plain text. Optimal someone has an idea how to repair this html with preg_replace, iterations and/or recursion.

 

If i have tomorrow access on my working environment, i will post further information.

 

 

Kind regards,

 

Butzman.

 

 

/edit:

I need to handle inline-tags (<STRONG><EM><U><STRIKE>). IE creates invalid html by inserting that tags on  '<P> </P>' blocks.

 

My first approach was too search for:

Begins with <INLINETAG>

followed by anything but not </INLINETAG> and not </P></INLINETAG>

followed by </P></INLINETAG>

 

Replace with <INLINETAG>$1</INLINETAG></P>.

 

But i had no success, because i could not create the not </INLINETAG>... expression.

Look-around expression was unsuccessful, too: ($!^(.)*</INLINETAG>(.)*$)

Link to comment
https://forums.phpfreaks.com/topic/198222-repair-ie-rte-html-with-regexp/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.