What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 131 Stack Exchange communities.

I'm don't know if the <pre> and <code> tags are supposed to exhibit the same behavior.

Part of the reason I don't know is that I can't seem to find any documentation for the <code> tag.

Anyway, the <pre> and <code> tags exhibit a different behavior in a case where I would expect them to behave the same way. It appears that a line starting with #include is breaking the Markdown engine in the <code> block.

The following Markdown

<code>
#include <stdlib.h>
int main(void) { exit(1); return 0; }
</code>

is rendered as:

include

int main(void) { exit(1); return 0; }

while the following Markdown

<pre>
#include <stdlib.h>
int main(void) { exit(1); return 0; }
</pre>

is rendered as:

#include 
int main(void) { exit(1); return 0; }
share|improve this question

1 Answer 1

<code> is pretty much a semantic element. It just tells the browser "This is code".

<pre> (meaning "pre-formatted") is a block-level element, and as thus disables Markdown parsing within that block.

That said, why would you write that stuff by hand anyway and not just use Markdown's 4-space-indent codeblocks, like you did in your question here?

share|improve this answer
    
I want to paste a chunk of code from an external editor into the entry box, and I find it easiest to wrap it with <code></code>. It seems to me that <code> blocks should be treated like markdown codeblocks. –  McKay.CPP May 27 '11 at 10:31
11  
@McKay.CPP: Just highlight the text and click the code button (or press Ctrl-K). Seems easier to me. And re It seems to me that <code> blocks should be treated like markdown codeblocks. -- we're certainly not going to redefine HTML. –  balpha May 27 '11 at 10:33
    
@balpah re: we're certainly not going to redefine HTML -- funny. That's exactly what markdown is already doing with the <pre> tag. HTML tags are allowed in <pre> blocks, but not in markdown <pre> block. As far as ease w/ Ctrl-K vs wrapping w/ tags - to each his own. I still prefer wrapping with tags as it doesn't modify the text. I was under the false impression that <code> gave markdown code-block like results. The markdown help section on code spans gave me that impression. –  McKay.CPP May 27 '11 at 11:12
    
just re-pinging with the right @ name since I cannot edit comments. –  McKay.CPP May 27 '11 at 12:25
2  
@McKay.CPP you don't need to include my name. You're commenting on my post, so I'll be notified regardless of who (or if) you @mention. –  balpha May 27 '11 at 12:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .