asu-ke-web-services / wp-front-end-editor

Front End Editor (works with or without wpautop)
2 stars 1 forks source link

HTML Comments can break markup #36

Open rraub opened 8 years ago

rraub commented 8 years ago

If you have a page with:

<ul>
  <li>blah</li> 
<!-- anything -->
  <li>foo</li> 
</ul>

it will show up when you click edit in page as:

<ul>
  <li>blah</li> 
</ul>
<p><!-- anything --></p>
<ul>
  <li>foo</li> 
</ul>

(And we do have wpautop off) It breaks up the list with the commented out html. Comments in general are not going to survive well in a front end editor like this, however they shouldn't have a negative effect on the pages layout like this. This is probably a TinyMCE issue, but we should make sure its addressed.

chasethenag420 commented 8 years ago

I investigated this issue and this is occurring due to wpautop. I will further check to see if it can be handled.

idmontie commented 8 years ago

:+1: It's always wpautop lol

chasethenag420 commented 8 years ago

Further analysis shows that tinymce is also formatting non block elements and here it identifies comment as one of the non block elements and adding <p>. I couldn't get a clean fix as it is being changed in two places one time by wpautop and other time by tinymce. Three solutions possible:

  1. Declare it as block element it won't add <p> tag -- needs change in core library files of wordpress and tinymce so not feasible.
  2. Fix the markup after running wpautop and after tinymce SetContent -- Trying to make it work but till now no success. wpautop got fixed, figuring out tinymce callback after SetContent
  3. Remove comments any where inside <ul> tag -- Original content comments may be lost so not inclined towards it.