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.
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.
You could write a shortcode to pass your Java code into that runs
htmlentities
on it. That should get it to display correctly.Usage:
WP thinks your Java code is HTML code. Essentially, make it HTML code instead.