How to strip   ?

Highlighted
Shopify Partner
115 0 7

I'm trying to remove all the   from product descriptions with liquid. But this character seems to be untouchable.

Specifically I'm getting a lot of paragraphs that only contain a single   and I want to get rid of them.

This is what I have tried:

{{ product.description | strip_newlines | remove: '&nbsp;' | remove: '<p>&nbsp;</p>' | remove: '<p> </p> | remove: '<p></p> }}

There are some redundencies in there. I'm just trying to find something that will work.

 

I even tried using strip but that won't even get rid of them.

{% assign descArr = product.description | split: "<p>" %}
{% assign desc = "" %}

{% for p in descArr %}
  {% assign paragraph = p | strip | prepend: "<p>" %}
  {% assign desc = desc | append: paragraph %}
{% endfor%}

{{ desc }}

 

1 Like
Tourist
15 0 1

For anyone having this problem today:

You actually have to copy a non-breaking space character.

Here's what worked for me, it looks as though I am replacing a space with a space but the first character is actually a non-breaking space.

{{ product.description | replace: ' ', ' ' }}

 

me@georgebutter.com
1 Like