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

Is there a way to highlight code on the index page? #6

Closed anthonyalberto closed 11 years ago

anthonyalberto commented 11 years ago

Hello, following my comment on StackOverflow, I'm posting my question here :

My blog is there : http://aarails.com

Is there a way to "prettify" code on the index page? For some reason, the markdown JS code isn't included on this page. But everything works fine on the article page.

Is there maybe a wordpress filter I can add to the plugin code to make it include the markdown JS on this page too?

Any help is appreciated, thanks!

frankielc commented 11 years ago

Also on the board on this one. Would be outstanding if it could display highlighted code on the homepage.

Thanks!

dantewang commented 11 years ago

Did a small hack.

In wp-markdown.php, function loadPrettify(),

add || is_home() after return is_singular($savedtypes), like this:

function loadPrettify(){
    // ...... existing code

    return is_singular($savedtypes) || is_home();
}

By doing this, prettify.js will be also loaded on "home page" so that the code block will get formatted by prettify.js.

Maybe there should be an option in the settings to enable people who want this to get this function.

stephenh1988 commented 11 years ago

As requested here and in http://wordpress.org/support/topic/prettify-code-not-working-in-some-views - I'm marking this for 1.2 (next release).

If anyone wants to do a PR - feel free - but I'm looking for something which will only load the javascript when its needed!


On a completely unrelated note, what are people's opinions on #5 ?

stephenharris commented 11 years ago

Sorry for the wait on this one. This is finally fixed with f8acd3e1cb1f8a997e44cf9f737566a8fff22504 - I will leave it a bit before pushing to the WP repository so that any bugs came be spotted and fixed before then. Feel free to test it!