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

Copying Syntax Highlighter code will add spaces #253

Open
ctdealba opened this issue Jan 20, 2023 · 2 comments
Open

Copying Syntax Highlighter code will add spaces #253

ctdealba opened this issue Jan 20, 2023 · 2 comments

Comments

@ctdealba
Copy link

Reported in here: https://wordpress.org/support/topic/works-but-if-you-copy-code-and-wan-to-to-use-it-show-error/

It works and show code beautifully on pages, But if you copied that code and want to use it, the it shows errors, Looks like it add some spaces,

I tried it with php shorcode, and when i copied the code from the frontend of the page, It gives Parse error: syntax error, unexpected…

Our development team was able to reproduce this issue in Python:

Putting the following code in Syntax Highlighter, updating the post, copying the code to a new .py file and trying to run it shows that Syntax Highlighter is, indeed, adding some invisible characters to the code.

We also figured it out that the code works successfully on Chrome, but it crashes on Firefox.

@renatho
Copy link
Contributor

renatho commented Jan 20, 2023

More details about an initial investigation: p1674223519935029-slack-C8QJAM52B

@fjorgemota
Copy link
Member

| We also figured it out that the code works successfully on Chrome, but it crashes on Firefox.

For anyone that doesn't have access to Slack, the issue happens when you: Copy Python code (or code from any language more strict about spacing, really) from a Firefox browser without clicking twice on the block on the frontend.

This is the code I used for testing:

def hello(name):
    msg = "hello {}"
    if name == "test":
        msg = "bye {}"
    print(msg.format(name))
hello("world")
hello("test")

Note that using Chrome, OR clicking twice on the code shown in the frontend so it transforms to a textarea, fixes the issue successfully.

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

No branches or pull requests

3 participants