-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
:empty
selector in Retcon removes <br> elements incorrectly**
#70
Comments
Retcon uses Symfony's CssSelector component under the hood, and I'm not sure if that supports the There's a dedicated {{ entry.text | striptags('<br>') | retcon([
['removeEmpty']
]) | typogrify }} or {{ entry.text | striptags('<br>') | retconRemoveEmpty | typogrify }} ...if you ever want to remove {{ entry.text | striptags('<br>') | retconRemoveEmpty(removeBr=true) | typogrify }} |
Thank you for your response, but the Steps to reproduce:The following input text in CKEditor:
Results in the following HTML output: <p>
lorem
</p>
<p>
</p>
<p>
</p>
<p>
ipsum
</p> When using the following Twig code: {{ entry.text | retconRemoveEmpty }} The rendered front-end output is: <p>lorem</p><p> </p><p> </p><p>ipsum</p> Expected behavior:The Could you provide a solution or clarify if this behavior is expected? |
That's interesting; I was not aware of that behaviour. It seems specific to CK Editor output, as I'm not able to reproduce it with Redactor, or with raw HTML (i.e. something like I'll investigate; in the meantime if you need a quick fix you could do {{ entry.text | retconRemoveEmpty | replace('<p> </p>', '') | raw }} |
@romainpoirier Retcon v. 2.8.2 and 3.2.1 is out with a fix for this now, which should make the Btw, I tested the |
Description:
I'm using Retcon to modify my content, specifically to remove unnecessary tags. However, it seems that the CSS
:empty
selector is also targeting self-closing<br>
elements when it shouldn't:In this case, the
<br>
elements are being removed along with genuinely empty elements, which is unexpected behavior.Is this a bug? If not, how can I remove truly empty elements (e.g.,
<p></p>
) while keeping<br>
elements intact?Versions used:
"craftcms/cms": "5.4.3"
"mmikkel/retcon": "3.2.0"
Thank you!
The text was updated successfully, but these errors were encountered: