Gray background between words when paste content in Writer

Hi,

when I paste some content in a Writer document it creates often an empty spaces with a gray background between words.
I just copied a piece of text from a website, this:

and pasted it in a Writer document:

image description

Why there is that gray background for the space between two words ?

Libre Office version: as I know this problem is ever existed.

If you think this is a little problem… it is not. I have sometime documents whit HUNDREDS of gray squares like that.

The web page of my example is this:
https://github.com/paypal/paypal-checkout/blob/master/docs/paypal-rest-api.md

The HTML of that paragraph in the web pase is this:

Alex

The only cause I know of is that LO is showing you the space is a “non-breaking” one, so that two words will be kept together when word-wrapping takes place. See page 79 of the Writer 4.2 PDF manual.

The gray mark will not be printed. You can stop it showing on-screen by selecting “Tools”>”Options”>”LibreOffice Writer”>”Formatting aids” and removing the tick fom the “Non-breaking spaces” box. But I do not recommend this – the mark helps show up the source of problems when text is copied from websites etc.

Why LiberOffice is doing this? Do you have a reasonable explanation for this behavior?
Where can I find the Writer PDF manual ?
I haven’t found that document.
I honestly have no idea of what is the meaning of “Formatting Aid” and there is not a single line of explanation in that window.
Anyway unchecking the “Non-breaking space” checkbox is the solution for this problem.

Thank you.

Alex

You can download the PDF manual from the LibreOffice.org Get Help/Documentation Page. The manuals are still catching up with LO 5, so you you should find the Writer manual under “4.x guides”. But you might want to download the “Getting Started” manual as well. This does have an LO 5 edition.

Like any other well-behaved word-processor LO gives you the choice of seeing where a formatting aid is doing something something behind the scenes. The non-breaking space will be there because the author put it there. I prefer to see that it is there because copied text often has this connection where I might might not want it. But the choice is yours.

I disagree with you a little. Let me explain.
Other word processor (MS Word) just fill the copied text in the document, without the fancy “gray squares”. That is what probably 99.9% of the users want.
A well-behaved word-processor should provide the functionality to enable the visibility/highlight of that NBSP but that should not be enabled by default in my opinion.
My point is that this nice advanced feature should not be an “issue” for common users. But is nice to have.

The author (the original HTML document) does not have set any NBSP before that link. It has a simple space and can go on new line if required.
LO formatting aid put the NBSP also after the HTML anchor. I think it is converting the new-line character in paragraph to NBSP. Its reasonable but it can results in a “dirty” document sometime (there many NBSB everywhere, often non-sense).
I really appreciate your explanation. Thank you.

The gray does print out on all of my documents too and it’s a pain in the butt to delete every one in a document. I am not a computer guru and I do not understand what you guys are talking about as far as a fix…is there some one who can tell me in plain English, how to fix the gray spaces in the documents? LOL Thanks.

Your “empty space with a gray background” is a so called non-breaking space. HTML generators use this method to avoid problems with regular spaces. For example if you type 5 spaces like here between the X characters:

X X

the space between is shown as only one space. If you put in 5 non-breaking spaces the distance remains as wished:

X X

You easily can see the difference. For some reasons it is useful to use non-breaking spaces in word editing. If you have got a sum of “23 kg” at the end of a line the non-breaking space defeats the separation into two words…

You can insert the non-breaking space using Insert menu > Formatting mark in your texts.

It is possible to replace the non-breaking spaces by using Find And Replace tool. Copy or cut one of the non-breaking spaces into the search line and hit a space in the replace line and replace “all”, so all of the mentioned non-breaking spaces can be eliminated.

I don’t understand. The HTML code is this:
< p >If you want to use the advanced javascript integration, you will need a way to create payment tokens on your server side. The simplest way to do this is using the < a href=“https://developer.paypal.com/docs/api/payments/” >PayPal Payments REST API< /a >< /p >

There is no need for “non breaking space”, there are no " " at all in the HTML.

  1. Who is adding the non-breaking spaces?
  2. Why non breaking spaces are set with that useless bg?

I understood now the use of non-breaking spaces here.
I think that LiberOffice is arbitrary deciding that there is the NEED of a nbsp before an HTML anchor element (and probably other HTML elements).
The result is, in my opinion, a bad UX for 99% of the users.
The expert user that want use the NBSP is able to add nbsp whenever they want.
A common user just have to remove that “strange” gray background manually because a common user doesn’t not know how to do it differently.
Thank you for the pre