WordPress.org

Ready to get started?Download WordPress

Forums

Crayon Syntax Highlighter
[resolved] Crayon on comments (29 posts)

  1. Serkan Algur
    Member
    Posted 1 year ago #

    Hi there,

    Thanks for awesome plugin but i have a problem with Crayon.

    If i have a post without code, Crayon don't load, this ok. But when i get a comment with code to this post, Crayon don't work on standalone comments.

    But if i add some little code like echo "hello world" to post, crayon load properly, show post's and comment's code.

    How i can enable Crayon for "only" comments.
    Note: crayon on comments selected in option panel.

    Thanks

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

  2. akarmenia
    Member
    Plugin Author

    Posted 1 year ago #

    Thanks for pointing this bug out:

    https://github.com/aramkocharyan/crayon-syntax-highlighter/issues/21

    Might need some tinkering I think.

  3. Serkan Algur
    Member
    Posted 1 year ago #

    I might solved problem :)
    I wrote a simple function to use highlighting with shortcodes. I think you can use this. Sample for my highlighting (it works with highlight.js in here)

    function phpcode($atts, $content = "") {
    	return '<pre class="php">'.esc_attr($content).'</pre>';
    }
    function csscode($atts, $content = "") {
    	return '<pre class="css">'.$content.'</pre>';
    }
    function htmlcode($atts, $content = "") {
    	return '<pre class="html">'.esc_html($content).'</pre>';
    }
    function init_common_shortcodes() {
    	add_shortcode('html', 'htmlcode');
    	add_shortcode('php', 'phpcode');
    	add_shortcode('css', 'csscode');
    }
    
    function init_comment_shortcodes() {
      remove_all_shortcodes();
      init_common_shortcodes();
      add_filter('comment_text', 'do_shortcode');
    }
    
    init_common_shortcodes();
    add_filter('comments_template', 'init_comment_shortcodes');
  4. akarmenia
    Member
    Plugin Author

    Posted 1 year ago #

    Thanks! add_filter('comments_template') is the key I think. Crayon used to work with shortcodes but it's become a bit more complicated than that - you can write Crayon with mini tags, or pre tags also. I'm super busy with my uni project today, hopefully I'll have time by the end of the day. In the meantime I think your solution should be fine.

  5. akarmenia
    Member
    Plugin Author

    Posted 1 year ago #

  6. Serkan Algur
    Member
    Posted 1 year ago #

    Thanks :) When you release new version i will check functionality :) But code seems fine in github :))

  7. akarmenia
    Member
    Plugin Author

    Posted 1 year ago #

    Awesome!

  8. sebast1an_l
    Member
    Posted 1 year ago #

    Hi, i have this same problem like Serkan algur , but i wonth report another issue and i dont wonth create new topic. When i add code with marker html, to post, all code seem looks good, but when i put this same code to comments, marker html not see. Here is exsample

    http://sladvice.xcl.pl/advice/news/how-you-highlight-the-current-page/comment-page-1/#comment-18

    anyway great plugin.

  9. akarmenia
    Member
    Plugin Author

    Posted 1 year ago #

    Thanks, I had a try and it worked after I did this:

    http://ak.net84.net/crayon/converting-legacy-tags-to-pre/

    When you convert, it will turn that code into a pre tag, instead of the [php] legacy tag. I would prefer to add TinyMCE to the comments box, and I've added info on how to do that in "Comments" here:

    http://ak.net84.net/projects/crayon-syntax-highlighter/

  10. sebast1an_l
    Member
    Posted 1 year ago #

    hi , i try like you told, but it still not working.

    1. I use function in : Settings > Crayon > Convert exsisting Crayon tag ... , and turn on few option.

    2. Wer i must insert this function :
    backticks
    add_filter('comment_form_defaults', 'tinymce_comment_enable');
    function tinymce_comment_enable ( $args ) {
    ob_start();
    wp_editor('', 'comment', array('tinymce'));
    $args['comment_field'] = ob_get_clean();
    return $args;
    }
    backticks

    to enable support for Crayon comments by adding TinyMCE to the comment box ?

  11. akarmenia
    Member
    Plugin Author

    Posted 1 year ago #

    Sorry I should have mentioned that - it goes in functions.php on your theme. I'll reword that.

  12. akarmenia
    Member
    Plugin Author

    Posted 1 year ago #

    Ignore this post, totally wrong thread :P Let me know if it works.

  13. sebast1an_l
    Member
    Posted 1 year ago #

    im dont know what is wrong, i do exsactly by advice , and still i dont see marker html in my commnets, i check it at another theme but it is the same, but if i add commnets when im admin, marker show up.

  14. akarmenia
    Member
    Plugin Author

    Posted 1 year ago #

    I found a bug where the Tag Editor did not show for users who aren't logged in - the button was there but clicking it failed to load. This has been fixed. Also, make sure to enable this setting:

    Display the Tag Editor in any TinyMCE instances on the frontend (e.g. bbPress)

    Download the latest github zip.

  15. sebast1an_l
    Member
    Posted 1 year ago #

    I download the latest github zip. , enable setting "Display the Tag Editor in any TinyMCE instances on the frontend (e.g. bbPress)" ,and add filter to functin.php file in my theme, but still i have the same.

  16. akarmenia
    Member
    Plugin Author

    Posted 1 year ago #

    Does it work with the Twenty Twelve theme? The latest github version works for me in both admin and when I've logged out. It might be a theme issue.

  17. sebast1an_l
    Member
    Posted 1 year ago #

    No mate, with the Twenty Twelve theme, and latest github when ,i add filter to my function.php file i got critical error, i hope its not crash my blog. But still if i logged as admin , marker html show up in commnets.

  18. akarmenia
    Member
    Plugin Author

    Posted 1 year ago #

    Hmm, what was the critical error? Here's my theme file:

    https://www.dropbox.com/s/lwy2zkkua9yon1w/functions.php

    Without knowing the cause of the issue or being able to reproduce it myself my hands are tied :P

  19. sebast1an_l
    Member
    Posted 1 year ago #

    When i add filter to funstions.php file in Twenty Twelve theme, i get this message :

    Fatal error: Call to undefined function wp_editor() in /home/sladvice/domains/sladvice.xcl.pl/public_html/advice/wp-content/themes/twentytwelve/functions.php on line 463.

  20. akarmenia
    Member
    Plugin Author

    Posted 1 year ago #

  21. sebast1an_l
    Member
    Posted 1 year ago #

    Yeah ,i have version 3.2.1 ,when i change at wp3.5 TinyMCE working fine , now i see marker HTML in my commnents.
    Thanks for your help, have nice day.

  22. akarmenia
    Member
    Plugin Author

    Posted 1 year ago #

    No problem!

  23. msrosyidi
    Member
    Posted 1 year ago #

    There is a problem on the visual editor after clicking reply.
    I read the solution here, but it makes my wordpress blank. I don't know how to fix this.

    How about adding only crayon button to the comment area without another buttons?

  24. akarmenia
    Member
    Plugin Author

    Posted 1 year ago #

    Can you enable WP_DEBUG in wp-config and see what errors are printed on the blank screen?

  25. msrosyidi
    Member
    Posted 1 year ago #

    After enabling wp_debug I only get this warning: Parse error: syntax error, unexpected end of file in D:\UniServer\www\belajarthemewp\wp-content\themes\twentytwelve\functions.php on line 484

    The code I add to the functions.php is exactly the same as here.

    And the line 484 is the last line of the code.

    If I delete the code, the problem is the visual editor cannot be used after clicking reply button

    Is there another solution? I'm not a coder.

    I'm sorry and thanks.

  26. akarmenia
    Member
    Plugin Author

    Posted 1 year ago #

    Yeah that's ok, I'll add a setting to do this automatically :) This is caused when you break the structure of the code by removing curly braces or php tags.

  27. akarmenia
    Member
    Plugin Author

    Posted 1 year ago #

    Try the latest beta: https://github.com/aramkocharyan/crayon-syntax-highlighter/archive/master.zip

    TinyMCE is automatically added to the comment box when the Tag Editor is enabled on the frontend

  28. msrosyidi
    Member
    Posted 1 year ago #

    Thanks.
    Yes, but unfortunately, the problem after clicking reply button still exist on the visual editor (there is no problem when using the text/html editor).
    After clicking reply, the visual editor cannot be used to write anything. I don't find any notice even the wp_debug is enabled.

  29. msrosyidi
    Member
    Posted 1 year ago #

    Actually I only need the functionality given by WP Syntax Highlighting (screenshoot).But this plugin out of date and gives many warning when wp-debug is enabled but still work.

    I think the functionality given by WP Syntax Highlighting is better than enabling all buttons of tinymce (because I prefer to use CKEditor when I need a wysiwyg editor on comment area).

    I'm sorry and thanks.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic