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.

With some Java generic code in a code block, ie:

List<Integer> l = new ArrayList<Integer>();

WP-Markdown was treating as HTML, and no matter what I did, the code above got turned into something like

List<Integer> l = new ArrayList</Integer><Integer>();</Integer>

Is there any way to get WP Markdown to behave better with this kind of code? Gist and (clearly) Stackexchange don't have this problem.

share|improve this question

2 Answers 2

I was trying to fix this for the longest time as well. It seems that the problem is not the rendering, but the editor - when you save, it updates your post.

I found a checkbox under Settings -> Writing called "WordPress should correct invalidly nested XHTML automatically". Unchecking this checkbox fixed the problem.

share|improve this answer

You could write a shortcode to pass your Java code into that runs htmlentities on it. That should get it to display correctly.

function clean_java($atts, $content)
{
    return htmlentities($content);
}

add_shortcode('clean_java', 'clean_java');

Usage:

[clean_java]List<Integer> l = new ArrayList<Integer>();[/clean_java]

WP thinks your Java code is HTML code. Essentially, make it HTML code instead.

share|improve this answer
1  
You would think this would happen automatically for a code block... –  Doug T. Feb 22 '13 at 13:39
    
Yea, not sure what WP's code markdown actually does. –  Nicholas Pickering Feb 22 '13 at 15:23

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.