WordPress.org

Ready to get started?Download WordPress

Forums

Crayon Syntax Highlighter
[resolved] Problem with copied code from Chrome (18 posts)

  1. nickelfault
    Member
    Posted 2 years ago #

    I'm thinking this may be a chrome bug since it doesn't happen in any other browser but I'm not 100% sure. When I copy the raw code from a crayon snippet in Chrome and paste it into a file, it seems to copy some bad characters. It appears to be the spaces that get corrupted. When I copy perfectly valid code and save it to a PHP file and try to run it, I get an error message similar to the following:

    PHP Parse error: syntax error, unexpected T_STRING, expecting T_FUNCTION...

    I have tried this with two different editors (PhpEd and Notepad++) and both have the same result.

    Here are the steps to reproduce the error:

    1. Copy the (plain text) code from the 'Other Methods' section of this page: http://www.hoffsays.com/2012/06/12/custom-404-not-found-error-pages-in-cakephp-2-0/
    2. Paste it into an editor wrapped in <?php ?> tags.
    3. Remove "App::uses('ExceptionRenderer', 'Error');" and " extends ExceptionRenderer" and save the php file.
    4. Try to run the file on your local server and you'll get the error.

    I did a little digging with Firefox and Firebug and I think it's related to the   entities that are in the textarea. Should these be actual spaces instead of   in the textarea?

    Again, this might be a Chrome bug but I know you could fix the issue a helluva lot faster than it would ever get fixed in Chrome.

    http://wordpress.org/extend/plugins/crayon-syntax-highlighter/

  2. akarmenia
    Member
    Plugin Author

    Posted 2 years ago #

    Quite right!

    
    class AppExceptionRenderer {
    
    Â Â Â Â /*-------------------------------------------------------------------------*/
    Â Â Â Â /* -- Exceptions
    Â Â Â Â /*-------------------------------------------------------------------------*/
    
    Â Â Â Â public function notFound($error) {
    Â Â Â Â Â Â Â Â $this->controller->beforeFilter();
    Â Â Â Â Â Â Â Â $this->controller->set('title_for_layout', 'Not Found');
    Â Â Â Â Â Â Â Â $this->controller->render('/Errors/error404');
    Â Â Â Â Â Â Â Â $this->controller->response->send();
    
  3. nickelfault
    Member
    Posted 2 years ago #

    Oh wow I don't even get those funky A's, I just get "invisible" characters in my editors! Maybe only encode the <, >, and & symbols (http://stackoverflow.com/questions/2502360/html-textarea-tag-how-to-correctly-escape-html-and-javascript-content-displa)?

  4. akarmenia
    Member
    Plugin Author

    Posted 2 years ago #

    Ok, fixed it. It was putting &nbsp into the textarea as well, fixed now. Remove Crayon and re-download 1.9.8 again.

  5. nickelfault
    Member
    Posted 2 years ago #

    Thanks for fixing it! Won't I lose all my crayon settings if I remove it and re-install?

  6. akarmenia
    Member
    Plugin Author

    Posted 2 years ago #

    Nope, it uses the WP options API so it's all in the database ;) Only way of reseting it is removing the entry in the database or clicking reset in settings.

  7. nickelfault
    Member
    Posted 2 years ago #

    Hmmm I still seem to be getting the same thing

  8. akarmenia
    Member
    Plugin Author

    Posted 2 years ago #

    Well yes, they'll need to update it on their site first for it to kick in :) Oh, if it was your site, then download this and replace the file:

    https://dl.dropbox.com/u/33811812/Crayon/minor/crayon-syntax-highlighter-1.9.8-minor-2.zip

  9. nickelfault
    Member
    Posted 2 years ago #

    Yup it's my site, I deleted & updated and still same thing. Tried replacing with the file you added too and still having problems :(

  10. nickelfault
    Member
    Posted 2 years ago #

    The & nbsp; still seems to be breaking it

  11. akarmenia
    Member
    Plugin Author

    Posted 2 years ago #

    It's unlikely, but perhaps the code has been created with the spaces in the actual post?

    It works fine here running 1.9.8:

    http://aksandbox.webege.com/?p=97

  12. nickelfault
    Member
    Posted 2 years ago #

    I just checked the DB, and it's tabs for indentation instead of spaces. Does crayon replace tabs with spaces?

  13. nickelfault
    Member
    Posted 2 years ago #

    I think that is the problem. Somewhere you must replace the tab character with 4 (html encoded) spaces?

  14. akarmenia
    Member
    Plugin Author

    Posted 2 years ago #

    Yep, or whatever it is in the settings. The new file here fixes that by leaving the code as is in the textarea (which is what it should really do):

    https://dl.dropbox.com/u/33811812/Crayon/minor/crayon-syntax-highlighter-1.9.8-minor-3.zip

  15. nickelfault
    Member
    Posted 2 years ago #

    Jackpot! Works like a dream, thanks a bunch for fixing it so quickly! I love that it retains the tabs now too!

  16. akarmenia
    Member
    Plugin Author

    Posted 2 years ago #

    Seems more semantically correct that way at least, glad you got it working, and thanks for filing the bug :)

  17. nickelfault
    Member
    Posted 2 years ago #

    No problem, thanks for the amazing plugin!

  18. nickelfault
    Member
    Posted 2 years ago #

    Marking as resolved.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.