- Issue created by @vector_ray
- πΊπΈUnited States jess_m
I came across the same problem in the project I'm working on. For a quick fix solve until the solution is found for the module, in a custom module we built for templates, for the twig variable it turned into: *note, field_name is just an example
{{ field_name|render|replace({' ':' '})|raw }}
and it now prints it out correctly both on the page and in the WYSIWYG. It's an immediate quick fix.
- πΊπΈUnited States vector_ray
I have created a merge request that escapes
and--
from the HTML before passing to XML. - πΊπΈUnited States mortona2k Seattle
This didn't clear up my errors with appendXML:
parser error : Specification mandates value for attribute async
The offending line is:
<script async src="https://public.codepenassets.com/embed/index.js"></script>
Warning: DOMDocumentFragment::appendXML():
Warning: DOMDocumentFragment::appendXML(): ^
Warning: DOMDocumentFragment::appendXML(): Entity: line 12: parser error : attributes construct error in Drupal\embedded_content\Plugin\Filter\EmbeddedContent->process() (line 106 of modules/contrib/embedded_content/src/Plugin/Filter/EmbeddedContent.php).
This is for a codepen oembed plugin, the errors seem to be coming from the template:
<p class="codepen" data-height="300" data-default-tab="html,result" data-slug-hash="RwEgNJE" data-pen-title="Menu columns" data-user="mortona42" style="height: 300px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;"> <span>See the Pen <a href="https://codepen.io/mortona42/pen/RwEgNJE"> Menu columns</a> by Andrew Morton (<a href="https://codepen.io/mortona42">@mortona42</a>) on <a href="https://codepen.io">CodePen</a>.</span> </p> <script async src="https://public.codepenassets.com/embed/index.js"></script>
- πΊπΈUnited States vector_ray
mortona2k async attribute needs to have a value to pass xml validation. Try
async="true"
. - πΊπΈUnited States mortona2k Seattle
That's a copy of the embed code from codepen. I could adjust it myself to get this working.
The same code is used by the Codepen module, but there it is implemented in a template and is not embedded into wysiwyg, so it doesn't encounter this issue.
This is a weird quirk, seems like we're using an XML parser to pass the HTML chunk, but it's still flagging things that are ok in html.
If these are new/different issues, I'm more inclined to adjust the embed code an add async="true" so we can close this ticket. Doing that clears up the warnings.
- πΊπΈUnited States vector_ray
I think this call needs to be made by the maintainer. As I mentioned in the description we can either try to process the HTML before passing through the XML parser like the patch here, in which case we might find more and more cases where the solution might produce errors. Or revert to the previous version solution as seen here: https://git.drupalcode.org/project/ckeditor5_embedded_content/-/blob/1.0...
@nuez
- π³π±Netherlands groendijk
Yeah, can confirm the CKEditor5 version of the function `process` does the trick. It's not only
or--
. Some other html might not be accepted as wel like<br>
(without trailing slash). - π©πͺGermany ckaotik Berlin
I'm wondering, do we really need to use DOM parsing? Or couldn't we simply pass the generated markup as a text replacement for the
<embedded-content>
tag, using a simplestr_replace
(multibyte, probably). - πͺπΈSpain nuez Madrid, Spain
I've revised this and reverted largely to the old way in the previous module, with the addition of the HTML::normalize from https://www.drupal.org/project/embedded_content/issues/3479770 π Warning: DOMDocumentFragment::appendXML() when input is not normalized Needs work . let me know if you find more issues