Yes, I've read Writeup Formatting Tips and Perl Monks Approved HTML tags and I'm well aware that <pre> tags are discouraged here, in general — for a number of good reasons which I do appreciate and normally abide by.

Still, occasionally, I use <pre> tags in place of <code> tags, because the former allow you to embed HTML markup, such as <b> or <i>, which will be honored when the <pre>-formatted section is rendered. IMHO, this does have its uses in a few selected cases, e.g. to highlight specific fragments in some program output, in order to make things easier to read.  As far as I know, this is not possible within <code> sections (at least, I wouldn't know how).

With this reasoning in the back of my mind, I did make use of <pre> tags and <b>/bold highlighting in a recent node to have some debug output be rendered something like this:

...
Just used Second in Data
Methods are exported from First
First::import(): @EXPORT_OK = ...
After using First in Second
...

And that's what it looked like initially when I had posted the node. After having reloaded it about half an hour later, however, it looked like this

... Just used Second in Data Methods are exported from First <b>First::import()</b>: @EXPORT_OK = ... After using First in Second ...

apparently because someone had replaced the <pre> tags with <c> tags  (or do we in the meantime have an automatic mechanism which periodically goes through all nodes to replace any evil <pre> tags? — if so, I missed it being announced on What's new.)

Okay, not a big issue. But what particularly surprised me was the relatively short time frame within which this happened. Otherwise, it often takes a whole day or longer until considered nodes are finally being fixed, even if they display as some illegible blob of text and code all mixed up in one paragraph.

So I'm wondering what sin I have committed that made immediate action necessary :) — while the parent node, for example - which has been considered for not using code tags - is still waiting for some benevolent janitor's intervention at the time of this writing...

It can hardly have been the line length, because the longest line in the snippet in question is just 69 characters. Also, I can't imagine why anyone would want to one-click-download some dull debug output, or have the snippet be decorated with the line numbering that <code> tags optionally offer.

So, to recap, is there anything unconditionally wrong with using <pre> tags? If so, why not disable them entirely in the first place?


In reply to <pre> vs. <code> tags by almut

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.