Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy&Pasting HTML in Webkit browsers leaves straying   in the text #542

Closed
cyclaero opened this issue Jul 26, 2019 · 3 comments
Closed
Labels

Comments

@cyclaero
Copy link

cyclaero commented Jul 26, 2019

I am using ContentTools for editing my BLog for more than a year now. This contains quite a lot of text, and I want to have it nicely justified with automatic hyphenation enabled. Since the beginning, I noticed that after editing an article, it is full of strayed  ’s which in many cases defeat line breaking and hyphenation. So after editing, I enter the HTML code of each paragraph and remove manually these nonsense  ’s.

Finally the situation became sufficiently annoying, for me to start an investigation.

My findings:

  1. Editing text with Firefox (on Windows) does not show this issues, i.e. no left over undesired  ’s

  2. Editing text with Webkit based browsers (Safari on Mac, Chrome on Windows, Epiphany on GNOME3/FreeBSD shows the issue.

  3. Before and after any HTML tag of the copied text, Safari inserts <span class="Apple-converted-space"> </span> while Chrome and Epiphany insert <span> </span>. The thus embraced space char is not the normal one but unicode no-brake space U+00A0. And this finally becomes converted to &nbsp;.

For me, I solved this issue by replacing in ContentTools/build/content-tools.js on line number 8216

wrapper.innerHTML = html;

with:

wrapper.innerHTML = html.replace(/<span( class="Apple-converted-space")?> <\/span>/g," ");

Hopefully this helps people who find straying &nbsp;’s as annoying as I did.

@anthonyjb anthonyjb added the bug label Jul 26, 2019
@anthonyjb
Copy link
Member

Excellent description of the problem @cyclaero - thank you for the help identifying and the workaround for now.

cyclaero pushed a commit to cyclaero/ContentCGI that referenced this issue Jul 27, 2019
…'s upon copying and pasting see: GetmeUK/ContentTools#542. So in ContentTools.HTMLCleaner.clean() strip out '<span> </span>' as well.
@anthonyjb
Copy link
Member

@cyclaero The next release will include your workaround so just wanted to say thanks again for the help with this.

karlkr pushed a commit to karlkr/ContentTools that referenced this issue Mar 30, 2020
@stalkergx
Copy link

Very helpful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants