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

When marking text as a code with <code> tag, it doesn't work properly with code containing `. Following two lines should look the same:

<pre>code `sample`</pre>

<code>code `sample`</code>

but display:

code `sample`

code sample

Why isn't indentation/<pre> a solution? Because you cannot use it to mark inline code (like the one in this and previous sentence), for which you have to use <code> or ``.


As for Cody's "solution" with using only markdown:

  1. type a text containing single back-tick somewhere in the middle
  2. mark part of the text
  3. click {} button
  4. result is not correct: "and example with back-tick in it"`


There is second related bug, this produces unexpected behaviour:

<code>`</code> <code>`sample`</code>

is shown as

</code> <code>sample`

share|improve this question
    
They look the same to me - except for the backticks. –  pavium May 3 '11 at 10:02
    
I think it works as designed; if you need to use backticks, you can indent the code with four spaces. If I recall it correctly, the syntax highlighting is handled by Prettify. –  kiamlaluno May 3 '11 at 10:11
    
@pavium That is what @vartec is reporting: the backticks should be escaped in the second line, as they are in the first one. –  kiamlaluno May 3 '11 at 10:13
    
I see you've updated your question with some more "bugs". The problem is, you're mixing and matching formatting styles: HTML tags and Markdown. That's not supported. Pick one and stick with it. There are no notable limitations on how you can express yourself (and your code snippets) with the Markdown formatting that's allowed. –  Cody Gray May 3 '11 at 10:32
    
@Cody: hmm.. my.opera.com/freejerk/homes/files/bug-feature.jpg –  vartec May 3 '11 at 10:43
    
I didn't say it was a feature... –  Cody Gray May 3 '11 at 10:46
    
You did say that {} toolbar button works. Care to comment the 4 step example I gave? –  vartec May 3 '11 at 10:50
    
Can't repro that 4 step example. I've tried it multiple times. I get exactly the same result as when I type in text with a backtick that's intended 4 spaces. Coincidentally enough, that's all the toolbar button does. It indents each line by 4 spaces. The UI isn't that hard to use... –  Cody Gray May 3 '11 at 11:20
    
@Cody: Updated, you're getting indent, because you're marking whole line. It's not a question if UI is hard or not, it's the question that it doesn't work correctly. I think you're just trolling, because you know perfectly that you couldn't get format for that single backtick example in your answer just using the UI. –  vartec May 3 '11 at 11:31
    
Disagree. Still works fine for me. I guess I'm clicking the button in the right spot. –  Cody Gray May 3 '11 at 11:33
    
@Cody: yeah, and I'm probably holding it wrong too... You can take a look of source of my question if you cannot mark part in the middle of the text and click {} –  vartec May 3 '11 at 11:35
1  
@Cody: What vartec means is that you can use the {} toolbar button both for marking code blocks (indented by 4 spaces) and for marking inline code with backticks (pretty fancy and very useful). The latter, namely inline code marking, happens if less than one line is highlighted. Now vartec's complaint is: If you have my foo ` bar on a line, highlight foo ` bar and hit the code button, you will not get my ``foo ` bar``, but only single backticks, and that won't give the desired code formatting. –  Hendrik Vogt May 3 '11 at 13:08
add comment

1 Answer 1

There's a reason you aren't supposed to use the <code> tag when Markdown will work just as well. HTML tags should only be substituted for things that Markdown syntax doesn't natively support. In this case, of course, code formatting is fully supported, all you have to do is indent the line with 4 spaces, or use the handy toolbar button:

   Code Formatting button on the toolbar


The result looks exactly as you would expect:

code `sample`    // Markdown syntax, indented with 4 spaces

I wouldn't waste any time "fixing" this. You also don't get syntax highlighting with HTML tags, another reason to prefer the Markdown syntax.


so if you're saying that <code> is not necessary, how would you write inline code containing ``?

It works just fine for me: Here's some inline code with `` backticks

And by special request: Here's some inline code with ` a single inline backtick

For more tips, please see the related question: How can the backtick character ` be included in code?

share|improve this answer
    
Try to write first sentence of your answer preserving the formatting, but not using neither <code> nor ``. –  vartec May 3 '11 at 10:17
    
@vartec: Why? It'd be awfully hard to write it without a keyboard, too. That's what they're here for. –  Cody Gray May 3 '11 at 10:19
    
@Cody: so if you're saying that <code> is not necessary, how would you write inline code containing ``? –  vartec May 3 '11 at 10:23
    
    
@vartec: meta.stackexchange.com/questions/55437/… Works just fine for me. –  Cody Gray May 3 '11 at 10:26
1  
@Cody: It's a bit strange that you write "you aren't supposed to use the <code> tag". Then why is it implemented that you can use it? –  Hendrik Vogt May 3 '11 at 10:27
    
@Hendrik: There's a difference between things that you're allowed to do and things that you're supposed to do. It's allowed because it's essentially harmless, just like the <b> tag. But there's absolutely no point, since Markdown syntax provides a superior alternative. In this case, the alternative's superiority is even more noticeable, as you get syntax highlighting if you use the Markdown syntax, but not with the HTML tags. –  Cody Gray May 3 '11 at 10:28
    
@Cody: can you also show it working fine with unmatched backticks? –  vartec May 3 '11 at 10:45
    
@vartec: Done. Did you read the link I referenced in a previous comment? –  Cody Gray May 3 '11 at 10:48
1  
@Cody: OK, so maybe it should say "you aren't supposed to use the <code> tag unless you know what you're doing". <code> does have it's uses as I explain in the answer to the question behind the link in a previous comment. –  Hendrik Vogt May 3 '11 at 10:55
    
@Hendrik: Perhaps so. I'm merely answering here from experience: I've answered a lot of questions and left a lot of comments with code, both inline and in block form, and I've never had an occasion where I need to use it. It's possible that TeX has different requirements than SO. My point is more "don't use the <code> tag when Markdown works just as well for your purposes". –  Cody Gray May 3 '11 at 10:58
    
@Cody: I agree with that last point 100%. –  Hendrik Vogt May 3 '11 at 11:01
    
@Cody: FAQ says otherwise, <code> is valid way to mark code: meta.stackexchange.com/questions/22186/… –  vartec May 3 '11 at 11:13
    
@vartec: Erm, what part of that contradicts anything I've said in my answer? I've given you multiple possible solutions to your problem, and a developer has already marked this question with the status-bydesign tag. I'm not sure what more you're wanting here except to be argumentative. I'm not terribly interested in that. I didn't write the FAQ, and I'm not a developer on the site. Pick a fight with one of them. –  Cody Gray May 3 '11 at 11:15
    
@Cody: FAQ contradicts part of answer, where you say: "you aren't supposed to use the <code>" –  vartec May 3 '11 at 11:16
show 6 more comments

You must log in to answer this question.

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