I have such html:
<!-- somecontent -->
After updating the post I see:
<!-- somecontent -->
What can I do? What's this?
I read a lot of posts about this problem, but, I think, I don't understand only one: WHERE I have to insert all the rules? Such as
config.allowedContent = true;
config.extraAllowedContent = 'main';
or else? Because then I inserted in ckeditor.config.js I see no changes. It continue to insert to my html
Can somebody help me? I'll be very thankfull.
After longer investigation I think I found it.
Firstly I checked if CKEditor supports HTML5 tags at all, and it does. So it should not strip them or change at all. As you posted the
<main class="someClass"> was getting surrounded with
<p> </p> - this could happen if
main was recognized as an inline element instead of block one. I digged into
CKEDITOR.dtd and it turned out that
main exists and it is a block element. It should be fine.
To check if it's a CKEditor issue or WordPress I checked what was written into database and what the CKEditor was getting from it. The post/page content was as in the example below (the only difference was the new lines characters - as CKEditor formats the code):
<main class="someClass"> <p>There should be only 2 paragraphs inside the</p> <pre><main class="someClass"></main></pre> <p>element.</p> </main>
But the code returned for edit was different
<p><main class="someClass"></p> <p>There should be only 3 paragraphs inside the</p> <pre><main class="someClass"></main></pre> <p>element.</p> <p></main></p>
<main class="someClass"> was wrapped with
<p></p>, then CKEditor was fixing those paragraphs around block element and the result was as you posted:
<p> </p> <main class='someClass'> <p> </p>
After short debugging of WordPress core I found the place where those paragraphs were added - function
To be more precise, the 469 line which describes all block elements:
$allblocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|form|map|area|blockquote|address|math|style|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)';
and there is no
So you have some options:
Or report it, create patch/pull request and wait for the fix, then update without any risk ;)