Support » Plugin: Crayon Syntax Highlighter » [Plugin: Crayon Syntax Highlighter] Crayon on comments

  • Resolved Serkan Algur

    (@kaisercrazy)


    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/

Viewing 15 replies - 1 through 15 (of 28 total)
  • Plugin Author akarmenia

    (@akarmenia)

    Thanks for pointing this bug out:

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

    Might need some tinkering I think.

    Thread Starter Serkan Algur

    (@kaisercrazy)

    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');

    Plugin Author akarmenia

    (@akarmenia)

    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.

    Plugin Author akarmenia

    (@akarmenia)

    Thread Starter Serkan Algur

    (@kaisercrazy)

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

    Plugin Author akarmenia

    (@akarmenia)

    Awesome!

    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.

    Plugin Author akarmenia

    (@akarmenia)

    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/

    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 ?

    Plugin Author akarmenia

    (@akarmenia)

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

    Plugin Author akarmenia

    (@akarmenia)

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

    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.

    Plugin Author akarmenia

    (@akarmenia)

    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.

    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.

    Plugin Author akarmenia

    (@akarmenia)

    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.

Viewing 15 replies - 1 through 15 (of 28 total)
  • The topic ‘[Plugin: Crayon Syntax Highlighter] Crayon on comments’ is closed to new replies.