If you are pasting content into a CMS editor from Word, Google Docs, or even another web page, this is almost guaranteed to happen. Rich-text editors love to insert non-breaking spaces to preserve the spacing they see, and they hide them inside the HTML where you will never spot them in the visual view. The result is odd gaps before links, broken underline alignment, and sometimes an extra space that pushes a link onto a new line.
First, prove it to yourself. Open the post in the source or 'code' view and search for <a. You will usually find dozens. It can also appear as the literal character U+00A0, which looks like a normal space in most editors, so search for both.
For one post, a careful find-and-replace in the source view works. For hundreds of posts, do it programmatically. Export the content (many CMSs give you an XML export), load it with a parser rather than regex if the structure is complex, and replace both the entity and the raw character with a normal space, then collapse doubled spaces. In Python, something like text.replace('\u00a0', ' ').replace(' ', ' ') before a re.sub(r' {2,}', ' ', text) gets most of it.
Then fix the source of the problem: paste into the editor using 'paste as plain text' (Ctrl+Shift+V in most editors) and add links afterwards. Prevention beats cleanup every time.
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
If you are pasting content into a CMS editor from Word, Google Docs, or even another web page, this is almost guaranteed to happen. Rich-text editors love to insert non-breaking spaces to preserve the spacing they see, and they hide them inside the HTML where you will never spot them in the visual view. The result is odd gaps before links, broken underline alignment, and sometimes an extra space that pushes a link onto a new line.
First, prove it to yourself. Open the post in the source or 'code' view and search for <a. You will usually find dozens. It can also appear as the literal character U+00A0, which looks like a normal space in most editors, so search for both.
For one post, a careful find-and-replace in the source view works. For hundreds of posts, do it programmatically. Export the content (many CMSs give you an XML export), load it with a parser rather than regex if the structure is complex, and replace both the entity and the raw character with a normal space, then collapse doubled spaces. In Python, something like text.replace('\u00a0', ' ').replace(' ', ' ') before a re.sub(r' {2,}', ' ', text) gets most of it.
Then fix the source of the problem: paste into the editor using 'paste as plain text' (Ctrl+Shift+V in most editors) and add links afterwards. Prevention beats cleanup every time.