I am trying to strip empty <P>
tags from a block of HTML within a Shopify theme. For some reason the remove
filter is not detecting whatever the space character is inside the tag. I’ve even tried copy/pasting from source code into my command and it’s not working.
{{ article.content | remove: '
' | remove: '
' }}
With this, it still remains:
Did you have luck with replace?
In addition, are these tags for sure coming from the article or is there a chance they could be being dynamically injected?
Thanks for the reply. Yes I have tried replace
as well. I even tried replacing all space characters with something else and the <p> </p>
remained in the raw HTML output. It seems to be some kind of other space character but everything I try can’t strip it out.
For the sake of testing, are you able to stripe out only the
?
Yes I can. But I can not strip out whatever Shopify thinks <p> </p>
is.
Hi @Louis_Walch ,
You can try with code: {{ article.content | remove: ‘
’}}
Or the best way, go to the articles, edit each HTML of the content, it’s the best way: https://i.imgur.com/ZN2ODqB.png
Hope it helps!
I ended up cleaning it up with Javascript. Maybe not the best solution but liquid just seemed to limited and was not cooperating.
If anyone needs it:
.replace( / /g,'' ).replace(/<p><\/p>/gi, '').replace(/<div><\/div>/gi, '')