aramk / crayon-syntax-highlighter

Syntax Highlighter supporting multiple languages, themes, fonts, highlighting from a URL, local file or post text.
https://wordpress.org/plugins/crayon-syntax-highlighter/
GNU General Public License v3.0
1.1k stars 248 forks source link

Using crayon with Timber #382

Open CROSP opened 8 years ago

CROSP commented 8 years ago

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 commented 8 years ago

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