6

I edited a question today and used <pre> instead of markdown for the post. This specific example what somewhat out of laziness with scrolling, but since HTML is accepted I didn't think it would matter to much.

I checked the latest edit and found the HTML had been replaced with markdown and commented "markdown is preferred to HTML". I gathered this was down to easier editing for users who don't know HTML, but I am curious to know if there is a specific [technical] reason for this preference?

  • Just a quick note: if you're posting a question regarding another editor's behaviour, you might also want to leave that editor a courtesy note about it (e.g. in the chat, or as a comment on one of their own posts), so they can come and offer their own take on the matter. Not everyone who's active on SU also frequents Meta. – Indrek Apr 9 '14 at 8:24
  • @Indrek | Apologies, I shall bare this in mind. It was more a general question which was prompted by the edit rather than anything against you specifically. Thanks for the answer also :) – Matthew Williams Apr 9 '14 at 8:44
  • No problem :) And congrats on reaching 2k rep. – Indrek Apr 9 '14 at 9:04
9

The reason Markdown is preferred over HTML markup is that it is readable. HTML markup does not provide anything helpful to the reader unless they know what the HTML element means (and maybe even how it is formatted on our site).

Why Markdown is preferred is not as apparent with a code block, because it might just be an indented block of text.

However, it becomes very apparent with lists, for example.

Additionally, if it was one day decided to change how certain things are rendered from Markdown, then all HTML-based posts wouldn't be affected.

Thus, we generally prefer Markdown over HTML.

Now you could ask if simply changing from a <pre> markup to the Markdown equivalent is a valid edit. I would say it might.

I have seen some really weird rendering issues with posts where people use <code> tags and I've edited those just for that reason.

  • Well, I stand corrected then! – Canadian Luke Mar 26 '14 at 16:51
1

A bit late, but since I believe it was my edit that @MatthewWilliams referred to, I thought I'd chime in as well.

So a couple more reasons, in addition to the ones Oliver Salzburg mentioned:

  1. HTML must be edited manually, the formatting toolbar (including its useful keyboard shortcuts) doesn't work. For instance, I've seen edits that have erroneously included other parts of a post in a code block that don't actually belong there. With HTML the closing </pre> tag would have to be moved manually, whereas with Markdown one can simply select those lines and click the { } button (or hit Ctrl+K) to outdent them. Same applies to other elements as well, like lists (multi-level lists in particular are far easier to edit when they're formatted with Markdown).

  2. The formatting toolbar also doesn't always properly work with HTML. For instance, if you try to format a <pre></pre> block as a blockquote (e.g. when the code is a part of longer text that has been copied from an external link), some of the lines can get mashed together. This doesn't happen when it's been formatted with Markdown.

  3. Stack Exchange sites allow a fairly limited subset of HTML tags. If, for whatever reason, an HTML tag is removed from that list (unlikely, but still), posts that use it might break. That's not really a concern with Markdown.

  4. Also worth noting is that the Markdown 4-space code block formatting doesn't render as <pre></pre>, but as <pre><code></code></pre>. I've seen some funky results when either tag is used without the other, and using Markdown avoids having to remember to type out both tags.

Now I don't generally edit posts for the sole purpose of changing HTML to Markdown, especially when there are no visible formatting issues, but on occasion when I see someone consistently using HTML, I might decide to leave them a little note regarding this. I apologise if I was too terse in this particular case; I'll try to explain more thoroughly in the future. (I also don't quite recall why I didn't leave a comment. Perhaps it was an improve-and-accept on a suggested edit and I figured an edit summary would suffice.)

Edit: ah, I found the post in question. I think in that case I edited because your own edit actually changed from Markdown to HTML, and I didn't notice it was just an edit conflict until afterwards.

You must log in to answer this question.

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