Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent CKEditor from fixing/correcting (invalid) HTML code

I have recently upgraded FCKEditor to the CKEditor module on a website powered by Drupal 6.

Some of the pages on the website have invalid (x)HTML, mainly block elements inside inline elements. Before anyone edits the page, the content is rendered live on the website as it should appear.

However when an admin goes to edit the page and the editable content appears in WYSIWYG view of CKEditor, it attempts to 'fix' the invalid code successfully.

My question is simply how to prevent CKEditor from re-writing the code in WYSIWYG view?

Here is example code: Should be / what I need:

<a class="link-block" href="index.html"><h2>My Header</h2><p>Some text.</p></a>

Result after editor save:

<h2><a class="link-block" href="index.html">My Header</a></h2><p><a class="link-block" href="index.html">Some text.</a></p>

Before I get scorned by anyone, I know code should be valid according to W3C specs however I didn't build the website and to re-code it all would be a monumental task.

like image 616
P3tro Avatar asked Apr 02 '26 08:04

P3tro


1 Answers

if you are using FCEditor with wysiwyg module, go to YOURSITE/admin/config/content/wysiwyg/profile/full_html/edit, then open the section "Cleanup and output" and uncheck "Verify HTML" option.

like image 138
Muhammad Reda Avatar answered Apr 03 '26 22:04

Muhammad Reda



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!