In this post over at tex.sx I'm trying to explain how one can mark inline code. To show backticks in inline code, I enclose the code in double backticks ``, and mostly this works. However, the very last inline code (inside a list) in that post doesn't render correctly. (UPDATE: I've fixed that post now.)

2nd EDIT:

I've managed to produce a short non-working example in the Formatting Sandbox. There, above the horizontal line I explain that <code>a<b</code> doesn't give a<b, and I use the code itself to demonstrate that it renders as a. This seems to mess up the double backticks later on. (Over at tex.sx, this was much later on.)

It seems that the reason for the bad rendering is wrong use of markdown as in <code>a<b</code>. I still say it's a bug: Try and edit my answer in the formatting sandbox. Then in the preview you see that everything renders as intended; preview and final output are different.

  • Have you tried escaped backticks \` ?
    – Felix
    Feb 1 '11 at 12:03
  • @Felix: In comments you can use escaped backticks inside inline code, but in questions and answers that doesn't work (as described at the link :-)). Feb 1 '11 at 12:09
  • @Hendrik Vogt: Mmh ok :) To be honest all that inline code and backticks in your answer made me feel dizzy ;D
    – Felix
    Feb 1 '11 at 12:11
  • @Felix: Mission accomplished! Feb 1 '11 at 12:12
  • @Hendrik, the above being tagged as [status-bydesign]: for the difference you describe between posts and comments, see Backslash escaping in code regions in comments.
    – Arjan
    Feb 1 '11 at 17:00
  • @Arjan: I have just no idea why Jeff tagged this "status-bydesign", but that doesn't come as a surprise; I'm getting used to not understanding his tagging :-(. Now what balpha did sounds really great, and "status-completed" fits. Nevertheless, thanks for the link. I didn't know that one, although I do know older related questions, as you can see in the comments there. (But the issue with \\ is not really related to my question here.) Feb 1 '11 at 18:58

I see your point, but you must be aware that there's a difference between using backticks to delimit code, and using <code> tags.

If you decide to use <code> tags, you're saying "I take the responsibility of creating the HTML myself, instead of letting Markdown do it."

If you do that, however, you also have the responsibility to create valid HTML. So if you have a left angle that could be mistaken to be the start of an HTML tag, you have to replace it with the corresponding character entity &lt;.

I am aware that <b technically is a valid SHORTTAG construct, but even the W3C discourages the use of these. For our intents here, they're plain forbidden; and either way this clearly isn't what you meant when typing <b.

Edit: We have made a change to the JavaScript preview that makes it behave more like the server-side version when handling invalid HTML. This probably doesn't catch all edge cases, but at least more of them. In particular, your examples now look just as broken in the preview as in the final version.

Considering that Stack Exchange is trying to reach more people who don't even know what "HTML" means (let alone "valid" HTML), it probably makes sense to at least make them aware of problems with their markdown as soon as possible.

This change will go live with the next build.

  • Thanks for your answer. While you were answering, I also updated my question, sorry. My main point is: The preview renders everything as expected, so I didn't notice the wrong output until several days later. (I accidentally deleted this important piece of information in the first edit of my question.) Feb 1 '11 at 15:23
  • That was really fast! Thank you very much indeed, this is exactly what I wanted, namely that my examples now look just as broken in the preview as in the final version. And yes, it is great to make users aware of problems with their markdown as soon as possible. Thanks again! Feb 1 '11 at 19:01
  • I just tested it in the sandbox, and it works great. Thanks a lot! Feb 2 '11 at 9:24

You must log in to answer this question.

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