crayon-syntax-highlighter icon indicating copy to clipboard operation
crayon-syntax-highlighter copied to clipboard

Using crayon with Timber

Open CROSP opened this issue 9 years ago • 1 comments

Hi, I have Wordpress Version 4.6.1 and Timber plugin installed. I noticed a problem with highlighting code.

Syntax is not highlighted on post page.

I have been trying to solve this problem for several hours but haven't found solution yet.

The problem is that ID is not generated inside post body [crayon-57de8bf6206ed683034980/]

It comes in simple text

<pre class="lang:java decode:true " title="Human Class">class Human {
    private int age = 0
    public void birthday() {
        age++;
        print('Happy Birthday!');
    }</pre>

I am not sure that the problem is because of Timber.

Manual formatting works

        require_once plugin_dir_path( __FILE__ ) . "..\..\crayon-syntax-highlighter\crayon_wp.class.php";
        $content = apply_filters('the_content', ($content));

        $content = \CrayonWP::highlight($content);

And interesting thing that [crayon-57de91f0bcdc5975011417/] (in my case) is displayed on Blog. Category, Archive ... pages.
But on full post page just simple pre tagged text.

Could you please help to find the problem, or at least place where the problem can be. Thanks

CROSP avatar Sep 18 '16 12:09 CROSP

I've found out that it doesn't work because the_posts hook is not called in post content.

CROSP avatar Sep 20 '16 19:09 CROSP