0

I've noticed that I cannot put a preformatted text here.

This works: tags <b>are</b> ignored here

This (four leading spaces) works too:

tags <b>are</b> ignored

However this (<pre></pre>) doesn't:

tags are not ignored here

Same here (<code></code>): tags are not ignored here

3
  • I'm not sure I understand what is different in some of these and how they should look, at least not as worded. Jun 17, 2012 at 14:28
  • @hippietrail Sorry, I didn't realise one doesn't see the tags from formatting. Updated OP.
    – texnic
    Jun 17, 2012 at 15:22
  • Ah now I think I understand. There must be some posts about this over on meta.SO as to whey they've chosen to do it this way. Hopefully somebody will dig around and post a link or two here. For this functionality would be for all SO/SF/SU/SE - not just us here... Jun 17, 2012 at 15:26

2 Answers 2

1

This is documented, but poorly worded.

https://stackoverflow.com/editing-help#code, then https://stackoverflow.com/editing-help#html.

See https://meta.stackexchange.com/questions/93795/editing-help-page-why-manually-escape-html for clarification.

1
  • Thanks. Probably they left it out for formatting comments or emphasizing something in long listings.
    – texnic
    Jun 18, 2012 at 7:11
2

This is absolutely intentional. The default way of writing posts is using Markdown. If you decide to handcraft your HTML, we assume that you know what you're doing, and thus preserve any HTML tags you write; after all, you'll have a reason for not using Markdown (and bolding of code is pretty much the only use case I can think of).

So if you insist on writing your own HTML for a code block, you have commit to this decision all the way, and &lt; escape your tags if you want them to be visible.

As a side note: Code blocks on this particular site seem to be of limited use to me anyway. I know there are people who like to use code spans (in `backticks`) as a way of emphasizing text (I noticed you have been doing it in a few places); that's hardly the intention of code spans, and usually comes at the cost of legibitlity.

3
  • Concerning legibility, we have more or less come to this conclusion too (meta.russian.stackexchange.com/questions/47), however couldn't agree on a better way so far as long as we don't have something like <quote> for inline examples. Any chance of getting such tag?
    – texnic
    Jun 18, 2012 at 13:13
  • What's wrong with quotation marks for marking quotations?
    – balpha StaffMod
    Jun 18, 2012 at 13:18
  • I see at least three problems: 1) quotation marks are used for other purposes too, 2) each post is likely to contain so many of them that it gets unreadable, 3) quotes can have quotation marks inside. The last one is survivable, but the first two are severe from my point of view.
    – texnic
    Jun 18, 2012 at 13:23

You must log in to answer this question.

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