You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There seems to be inconsistencies in how liquid the replace filter handles the entity. It cannot replace a that was in the string originally, but it can replace s that were added via liquid.
Example:
Page with a somewhere in the body content, with normal spaces everywhere else.
{{ page.content | replace: ' ', ' ' | replace: ' ', ' ' }} will convert all normal spaces to non-breaking spaces, and then all the new nbsps will be converted back to regular spaces. The nbsp present in the page content from the beginning will not be converted back.
Though the above example is obviously an intentional edge case, it could definitely be very useful in cases where a user has imported a large amount of content from elsewhere. Especially since in the rte code view, you cannot distinguish between a regular space and a . This would be useful in making sure content is consistently output.
The text was updated successfully, but these errors were encountered:
Liquid doesn't know anything about HTML entities itself. Somewhere along the line (maybe before saving to the database), is being converted to a UTF-8 "NO-BREAK SPACE" character, \u00A0.
Liquid does not support escaped characters in string literals, so you will need to use something that looks like {{ page.content | replace: ' ', ' ' }} where the first space is a real UTF-8 0xA0 character and the second one is a UTF-8 0x20. Note that copy/pasting from this page won't work due to something about GitHub's comment system, you'll need to generate it yourself. Here's a Ruby string you can use: puts "{{ page.content | replace: '\u00A0', ' ' }}"
There seems to be inconsistencies in how liquid the
replace
filter handles the
entity. It cannot replace a
that was in the string originally, but it can replace
s that were added via liquid.Example:
Page with a
somewhere in the body content, with normal spaces everywhere else.{{ page.content | replace: ' ', ' ' | replace: ' ', ' ' }}
will convert all normal spaces to non-breaking spaces, and then all the new nbsps will be converted back to regular spaces. The nbsp present in the page content from the beginning will not be converted back.A video example:
https://screenshot.click/02-39-ecwkn-j9v56.mp4
Though the above example is obviously an intentional edge case, it could definitely be very useful in cases where a user has imported a large amount of content from elsewhere. Especially since in the rte code view, you cannot distinguish between a regular space and a
. This would be useful in making sure content is consistently output.The text was updated successfully, but these errors were encountered: