stephenharris / WP-MarkDown

WP-MarkDown plug-in. Allows Markdown to be enabled in posts, comments and bbPress forums.
http://wordpress.org/extend/plugins/wp-markdown/
112 stars 19 forks source link

Code sample not "prettified" in posts #17

Closed pileon closed 11 years ago

pileon commented 11 years ago

During simple testing, it seems that code blocks are not prettified on either the preview page or the actual page for the post.

The code is on the other highlighted on the main page, and of course in the editor preview pane. But when you click the post to read the whole post (or comments) then the code is no longer highlighted.

I'm using WP-MarkDown version 1.2, installed from the plugin-finder in my installation.

The page in question: http://pileborg.se/2013/05/markdown-testing/

stephenharris commented 11 years ago

The link you give shows the code being highlighted... have I missed something?

pileon commented 11 years ago

I've checked, and it's highlighted nicely on Windows (tried multiple browsers), but not in Firefox or Chrome on Linux! Both Firefox and Chrome on Linux are the latest releases.

I'll have to check this when I get home from work, to see if it's just something weird with my computer at work.

stephenharris commented 11 years ago

That's odd, I'm using Chromium on Ubuntu, and it works fine with no errors in the console (Only a warning regarding a facebook-related script).

pileon commented 11 years ago

Please give me a couple of hours to check from home. If it looks fine (I'm guessing it will) I will close this, otherwise I'll try to debug it my self.

pileon commented 11 years ago

Of course it works fine at home. Closing.

pileon commented 11 years ago

Oops, I forgot to go into the actual page, where it doesn't work. I'll check it out close in the weekend when I have more time.

pileon commented 11 years ago

Okay, here's a new thing... I works when I'm logged out, but not when I'm logged in. My user has administrator rights.

pileon commented 11 years ago

I think I found the problem. In the file js/markdown.js you call editor.run() before you call prettify. I'm not fully sure what editor.run() does, but it does leave your ready function before it continues to the prettifying.

I solved this by moving the call to the end of the ready function:

if( $('#'+id ).length > 0 ){
    var converter2 = new Markdown.getSanitizingConverter();
    editor = new Markdown.Editor(converter2, id, { handler: help });
    // Doesn't work here
    // editor.run();
}

if (typeof prettyPrint == 'function') {
    prettyPrint();
    if( editor ){
        editor.hooks.chain("onPreviewRefresh", function () {
        $('.wmd-preview pre').addClass('prettyprint');
        prettyPrint();
        });
    }
}

// Run the editor here instead
if( editor ){
    editor.run();
}
stephenharris commented 11 years ago

@pileon

That editor is for when the comments are using the markdown toolbar. Thanks for solving this - I had been unable to replicate it on my test site.

Are you able to make a pull request?

pileon commented 11 years ago

Pull request sent.

On 2013-06-03 13:17, Stephen Harris wrote:

@pileon https://github.com/pileon

That editor is for when the comments are using the markdown toolbar. Thanks for solving this - I had been unable to replicate it on my test site.

Are you able to make a pull request?

— Reply to this email directly or view it on GitHub https://github.com/stephenharris/WP-MarkDown/issues/17#issuecomment-18834699.

stephenharris commented 11 years ago

Closing this because of #19 . Thank you! Will include this in 1.3.