tags:

views:

640

answers:

6

I'm writing a little bit of a wiki and going through all of my options for syntax highlighting. Debating between wiki syntax (mediawiki) and markdown + whitelisted tags. I think I would prefer the latter but I think my users will need tables. Why are tables disallowed here on Stackoverflow?

<table> <tr> <td> </td> </tr> </table>
+4  A: 

They serve no purpose in a Q&A format. At least I cannot think of a reason I would need to use a table to answer someone's question, or ask one myself.

Plus, you can do this anyway:

cell 1-1      cell 1-2
cell 2-1      cell 2-2

EDIT: So after reading comments on my reply, I see that there may be a few cases where a table could provide a better visual aid. So I'm going to recommend a markdown similar to CSV; I think that's easy enough to type and implement.

geowa4
what about a table of data, or a matrix, etc.
Shawn Simon
Just recently, I had to answer a question with the output of an Excel spreadsheet. It was a pain manually justifying all those cells - a table would have made it a hell of a lot easier. I also in the past have answered with booelan truth tables, that would also have been easier with tables.
paxdiablo
I agree with PAX, but believe then it better suits at UserVoice. not here.
Mohit Nanda
Apologies, @geo, I -1'ed you because I disagreed but then thought better since your answer **is** helpful (but painful), so here's your point back (I'm not gunna +1 you however :-).
paxdiablo
Tables are handled natively by Markdown. Actually, if you input the table-markdown, it's not saved with the message, so we can be sure that it IS being recognized by Markdown (just disallowed). I think tables should be allowed, personally.
Jonathan Sampson
+1  A: 

I think that it is arbitrary. There could be many uses for them, but it seems that manually aligning fixed-width text is preferred here (which I consider a hack).

Personally, I prefer the BBCode style syntax.

  • it is explicit
  • it is almost like HTML
  • it cannot be confused with HTML because of the use of brackets instead of angles

"explicit" means that any intended effect can be expressed in almost any combination, and there are no unintended effects (like in markdown, when one of the many special characters is used). For example, I have no idea how to get this site to display a word in asterisks in a non-fixed font (*word*). Morse code cannot use the underline, because it is also a special character. In BBCode, there is only one special character: [

Additionally, input sanitizing gets much simpler.

Svante
use backslash to escape in markdown ;p
Shawn Simon
to respond to your post, what i really like about markdown is that its highly readable in a text format. its just like old school text documentation. bbcode, html, wiki syntax and the rest lack this. but i will have to make a decision at some point. i will check out the bbcode table syntax. thanks
Shawn Simon
I think the brackets look horrible... I suppose that's just me :)
Lucas Jones
I don't like BBcode. It looks like HTML, but is not actually such. It as verbose as HTML but is not as powerful. It is not consistent: [img]URL[/img], but [url=URL]linktext[/url]. No way to provide alt attribute for images (shame!). [size], [color] and [attachment] are just evil.
jetxee
Well, yes, it is not HTML, but it is much more consistent than Markdown, and you can extend it quite easily.
Svante
+1  A: 

Consider that the Wisiwyg javascript editor (WMD) has to render what you are typing in real time
(an important feature wanted by Jeff from the beginning of SO)

Hence, I think dynamic update of table would be way too complex to parse/display, since the HTML translator would have to interpret incomplete table structures as you are typing them.
That means coping with features like colspan, rowspan, incorrect header structures and so on.

So to have a better dynamic preview experience, tables got scratch completely.

VonC
You could use the Visual Studio method of automatically creating close tags as you open them, although this wouldn't work in the case of copy/paste
ck
+1  A: 

There are many cases where tables would be useful: table of data, displaying a matrix, showing the possible outcomes of an algorithm, etc.

I don't think you need something as complex as HTML tables (with rowspan and all), plain CSV would be sufficient for 99% of use-cases, I think. It would also allow the javascript dynamic renderer to do its job easily.

CSV is well-known, light, simple to type and to understand. The only thing needed on top of that would be a start and end tag for CSV data. For example [csv]...[/csv] or ||...||. Here is what it might look like:

[csv]
**XOR**,**true**,**false**
**true**, false, true
**false**, true, false
[/csv]

This would produce a table like this one:

XOR     true    false
true    false   true
false   true    false

(with the first row and the first column in bold characters)

MiniQuark
+2  A: 

Disallowing tables would be a good idea if your site is built on top of tables and you can't write a regex that is good enough to validate that the users html is syntactically correct, otherwise your layout could be affected.

Even if your site is not table layed out, having two sets of malformed table html in comment posts etc. could lead to your site being defaced.

ck
Markdown prevents malformed tables from being created with markdown syntax.
Jonathan Sampson
+2  A: 

Three reasons:

  • compatibility with arbitrary Markdown implementations,
  • safe user input,
  • layout-independent content

Standard Markdown does not support tables. It is intended to be just like e-mail. SO uses standard Markdown, so no tables.

Some Markdown extensions support tables, but they are not compatible between each other, which invalidates the idea of Markdown, because the content becomes dependent on a particular Markdown implementation.

So, the tables can be made only with HTML-inside-Markdown. Which is also not good. I am sure that Markdown2PDF, Markdown2TeX and Markdown2TheNextBigML converters are easy to write. Converting Markdown with embedded HTML to anything but HTML is not trivial. So there is no point to store everything in Markdown (plain text), if (some) embedded HTML is allowed.

Another reason to sanitize all user-submitted HTML is obvious, it is too difficult and expensive to parse properly, and it can break the layout (e.g. <table width="10000" height="10000">).

Finally, there is a huge benefit in a lightweight (pure Markdown) markup: it does not depend on a particular site layout (screen width, paddings, margins, justification, column widths, etc.). So if a SO redesign happens a year from now, the content does not need to be edited (HTML snippets depend on a particular CSS implicitly). Additional bonus: easier to use in third party applications (like mobile phone clients).

jetxee
disallow attributes then
Shawn Simon
even tables without attributes can be unpredictably wide (<table><tr><td>longstringwithoutspaces</td><td></td></tr><tr><td></td><td>anotherlongstring</td></tr></table>)... but the point is to keep all the content future-proof and layout-independent.
jetxee