-4

Markdown formatting makes easier to write good looking questions and answers, but sometimes people use ASCII art (like above) to create tables or other symbols to make their question/answer more clear.

ASCII table

This is very handy if it is treated as raw text, but characters in these arts are Markdown keywords too, so it will turn these into something like this:

Markdown styled ASCII art

Even if we put the ASCII table to a blockquote or a code sample it still displayed wrong. For example in this question: MySQL and PHP Many-to-Many Database Relationships

Formatting ruined alignment

Here you can see that this process ruined the allign of the vertical lines.

Is there a way to turn off the Markdown converter tool so the pasted ASCII table will be displayed as plain/raw text? Some keyword/function like:

<rawtext>
Plain text here.
</rawtext>

If no, could we implement this function? Or in the other hand how should we treat ASCII tables/illustrations like this?

8
  • 3
    Do you have an example of a situation where a code block is not enough?
    – hammar
    Commented Apr 18, 2013 at 21:24
  • 2
    you can put it in a <pre> or wrap it in a code block with <!-- language: lang-none --> (to avoid coloration) Commented Apr 18, 2013 at 21:28
  • 15
    never use the tab character inside code block formatted text. Actually tabs should be instantly and irrevertibly burninated and converted to four spaces when copy pasting. On the link you've sent the code block uses tabs instead of spaces.
    – SztupY
    Commented Apr 18, 2013 at 21:31
  • 3
    Mixing tabs with spaces from the look of it. Disabling markdown wouldn't fix this, as there is no agreed-upon standard for what width a tab should be. Use spaces.
    – hammar
    Commented Apr 18, 2013 at 21:31
  • 3
    Although I asked something that can be solved with the site's features I don't think it deserves that many downvotes. It is a well formated/described question/problem that others can face too, so it is a good reference.
    – totymedli
    Commented Apr 18, 2013 at 21:50
  • 3
    Downvotes have different meaning here on Meta. They signify agreement or disagreement with what you've posted, not the quality of the question asked. The faq can provide more information.
    – Ken White
    Commented Apr 18, 2013 at 22:44
  • 1
    <rawtext>, almost like pre-formatted text?
    – user229044
    Commented Apr 19, 2013 at 3:47
  • 1
    I have a feel that you guys want to punish me with your downvotes...
    – totymedli
    Commented Apr 19, 2013 at 12:48

2 Answers 2

25

Use code blocks (4 spaces) with <!-- language: lang-none -->and NEVER use tabs inside them, as they can be misleading:

So this:

<!-- language: lang-none -->

    --------------------------------------------
    |                colour                    |
    --------------------------------------------
    |     colour_id     |     colour           |
    --------------------------------------------
    | 1                 |     blue             |
    --------------------------------------------
    | 2                 |     red              |
    --------------------------------------------
    ############################################
    --------------------------------------------

becomes this:

--------------------------------------------
|                colour                    |
--------------------------------------------
|     colour_id     |     colour           |
--------------------------------------------
| 1                 |     blue             |
--------------------------------------------
| 2                 |     red              |
--------------------------------------------
############################################
--------------------------------------------

After copy-pasting you can use the {} button to indent all your lines with 4 spaces (so they become code blocks). You will still need to remove all tab characters, and replace them with spaces though.

Related posts:

And the best meta topic ever:

10
  • 3
    I wouldn't recommend <pre> for this, as it's still sensitive to certain HTML characters like < and >. Indenting by four spaces is better.
    – hammar
    Commented Apr 18, 2013 at 22:10
  • That language identifier doesn't actually do anything. It just gets stripped as invalid HTML. Manual <pre> blocks never get syntax highlighted. Only Markdown-produced code blocks are eligible for syntax highlighting.
    – animuson StaffMod
    Commented Apr 18, 2013 at 22:16
  • yeah, you're right. changed the answer
    – SztupY
    Commented Apr 18, 2013 at 22:24
  • @animuson That's not quite correct. Anything that's <pre><code> will be prettified, whether Markdown-created or handwritten. You're right though that <pre>-only block never will be; they're not code after all :)
    – balpha StaffMod
    Commented Apr 27, 2013 at 6:00
  • @SztupY Can you clarify the problem with tabs you're describing? Ever since I rewrote the PageDown (then WMD-New) detabber, the tab behavior should be well-defined and consistent (not that that means you should be using them, of course).
    – balpha StaffMod
    Commented Apr 27, 2013 at 6:02
  • @balpha: The problem is that when you create a new post an paste in a tab, some browsers (tested with Chrome) will ident it to 8 chars, instead of 4. Therefore when it gets posted what was visible during posting (8 spaces) will become 4. The only solution for this would be if a javascript would automatically convert tabs into 4 spaces while creating / editing a post.
    – SztupY
    Commented Apr 29, 2013 at 10:13
  • @SztupY That's not right. The Markdown preview indents to four, not eight spaces. The only thing that may be displayed differently by browsers is the content of the input box.
    – balpha StaffMod
    Commented Apr 29, 2013 at 12:03
  • @balpha: that's what I'm saying. People usually look only at the input box when creating posts, especially code blocks, as they think that will just be exactly the same as in the input box (so "no need" to check the markdown rendering). And they're almost right: it will be the same. Except for the tab characters.
    – SztupY
    Commented Apr 29, 2013 at 13:28
  • @SztupY "People usually look only at the input box when creating posts" -- that's really a [citation needed].
    – balpha StaffMod
    Commented Apr 29, 2013 at 14:00
  • @balpha: sorry for the weasel words. I took that from the amount of posts I've seen inside the review queues having some of this issues.
    – SztupY
    Commented Apr 29, 2013 at 14:09
7

You can use the <pre> tag to work around this. For example:

--------------------------------
| colour                       |
--------------------------------
################################

You must log in to answer this question.

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