Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've found some themes for prettify.js and I want to use one of them on my blog. As the Theme Gallery says, I can just download one of the themes, rename the css file to 'prettify.css' and overwrite the original one, to apply a new theme.

However, since I am using WP-Markdown, the code blocks are formatted by the embedded prettify.js and this prettify.js is loaded by the plug-in code, and the plug-in directory doesn't contain any file named prettify.css.

The prettify.js the plugin uses doesn't seem to be the same one as google-code-prettify's.

So how should I apply a theme to this prettify.js?

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

So the css used by the plug-in is actually called demo.css - see file. ( I know, it started as that I've never got round to calling it something more appropriate). The plug-in requires more css that just prettify, however: for example to style the preview box, the toolbar etc. So just replacing the contents of demo.css with your prettify theme won't work.

But inside demo.css there are two lines which contain the compressed prettify theme. You should be able to replace that with any theme you want...

However, you should never edit plug-in files directly. Though in this case unlikely - doing so can have unintended consequences. But more importantly your changes are lost when you update.

So here's a better way to replace a plug-in's css file.

  1. Copy the css file into your theme (rename it wp-markdown.css, say - because that makes sense).
  2. Make any changes to the copy in your theme.

  3. De-register the default CSS and re-register your own copy

The code:

   add_action( 'wp_enqueue_scripts', 'wpse82441_wpmarkdown_replacement_style', 20 );
   function wpse82441_wpmarkdown_replacement_style(){
        wp_deregister_style( 'md_style' ); //Deregister the style
        wp_enqueue_script(
            'md_style', //Re-register the style
            get_template_directory_uri() . '/wp-markdown.css', //Point to the copy in your theme
        );
   }
share|improve this answer
    
Stephen, it would be much more kool if that would be two separated files. Core concatenates anyway in the backend and just removing the prettify and replacing it with the ones from the syntax highlighter I used would make more sense (to me). +1 –  kaiser Jan 24 '13 at 6:27
    
Core does not concatenate plug-in scripts/styles... –  Stephen Harris Jan 24 '13 at 12:33
    
Thanks. I would try that. –  coolcfan Jan 25 '13 at 7:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.