jquery/demos.jquerymobile.com

The 'view source' dialog on every demo, adds special white characters when copied to clipboard

oskosk opened this issue · 10 comments

The View source dialog on every demo, adds special white characters when the code is copied.

The NO-BREAK SPACE character is copied for every space instead of a regular whitespace.

The problem here (at least for me. it may happen in other cases) is that when trying the data-role=navbar inside a data-role=footer with data-position=fixed, jQuery mobile replaced all this strange characters for   thus breaking the layout erraticaly until I figured out that all indentation in the pasted code had that character instead of a regular whitespace

At least, I'm reproducing it using Chrome v40 running on Ubuntu 14.04.

I'm not able to test it on another platform right now.

Are you double clicking to copy from the text area or copying directly?

I made this jsbin http://jsbin.com/pejuyu/1/edit using text copied directly from the viewsource in chrome 40 OSX and i don't see any issues

I have to double click before being able to copy. If I don't do this, I can't select the code for copying it.

I've checked the jsbin , pasted some code copied from a view-source (the navbar snippets) and it doesn't get to be a problem there. It may be that JSbin is replacing those characters for regular whitespaces.

I noticed the issue using Sublime Text 3. But I double checked it pasting it into vim, saving to a file and doing an hexdump -C on the file. I attach a screenshot with this. The notable characters are the UTF8 C2 A0

The code I pasted on vim was the following ( from http://demos.jquerymobile.com/1.4.5/navbar/)

<div data-role="navbar" data-grid="d">
    <ul>
        <li><a href="#" class="ui-btn-active">One</a></li>
        <li><a href="#">Two</a></li>
        <li><a href="#">Three</a></li>
        <li><a href="#">Four</a></li>
        <li><a href="#">Five</a></li>
    </ul>
</div><!-- /navbar -->

screenshot from 2015-03-02 18 37 56

@oskosk can you try the demo here http://alexgorbatchev.com/SyntaxHighlighter/whatsnew.html under "no flash copy to clipboard" and see if you see the same thing?

Yes, same behavior if I copy the code after the double click.

If I copy the text without doubleclicking, then the text is copied into the clipboard with regular spaces (i.e. http://www.fileformat.info/info/unicode/char/0020/index.htm) .

I've checked with Chrome and Safari on an OSX 10.10 (Yosemite) and getting the same results when pasting into vi and doublechecking the characters with hexdump -C. The same weird whitespace is copied to clipboard.

Checked the jQuery 1.4.5 demos and SyntaxHighlighter docs

@oskosk Ok there is not much we can do here then ( the not being able to copy with out double click is a bug in the popup we already fixed in master ) but the space characters are in the syntax highlighter tool so we will gave to open a bug there.

@oskosk looks like there are several open issues related to copying spaces on syntaxhighlighter https://github.com/syntaxhighlighter/syntaxhighlighter/search?q=space&type=Issues&utf8=%E2%9C%93

👍 same problem here