Shopify removes   from the product description

Anastasiia_D
Tourist
11 0 2

I'm editing the product description in the html code editor mode, so I'm marking up where I use non-breaking space between a number and a unit of measurement. For example,

10 bar

But today I noticed that Shopify just deletes non-breaking space after switching to preview mode and back to code editing. However, Shopify itself places the   but not where I need them.

 

How does it work? Is this a Shopify error?

Replies 6 (6)

Speedup_guru
Shopify Partner
18 2 3

Hi @Anastasiia_D ! Most likely in your theme's code there is an escape string handler for this block, which removes all special characters. More details here: https://shopify.github.io/liquid/filters/escape/

Regards,Pavel Iakushenkov, Speedup.guru
Anastasiia_D
Tourist
11 0 2

I didn't even exited the product card editor. I just used the "code mode" button for the description, wroted the text and used "view mode" and then "code mode" again.

 

But thank you for your reply. This problem was temporary for me, but now everything is ok, I didn't notice it anymore.

NomtechSolution
Astronaut
1245 113 149

you could consider using CSS properties like white-space: nowrap; or adjusting the layout and styling to accommodate the desired spacing. Shopify's code editor has a feature that automatically removes non-breaking spaces ( ) when switching between preview mode and code editing mode. This behavior is intentional and not an error.

Anastasiia_D
Tourist
11 0 2

Thank you. Yes, I already use this method, it works well.

Digico
Shopify Partner
46 1 5

Not an error, Shopify with Liquid will escape characters (no left and right special chars). It's a normal behaviour.

TarikAndrukhiv
Shopify Partner
1 0 0

Hi ✌️

Just use a JSON filter and then replace the string with the correct view. Example: 

 

{%- liquid
  echo "<span>10&nbsp;bar<span>" | json | replace: '\u0026nbsp;', '&nbsp;' | replace: '\u003c', '<' | replace: '\u003e', '>'
-%}

 

Best
Tarik