visit1985/mdp

Ascii art is ugly

dsyer opened this issue · 10 comments

dsyer commented

I'm not sure what triggers this. At first I thought it was long lines (which are common in ascii art), but then I tried a quite thin "image" like this:

+--------------+
|              |
|              |
|              |
|   Box 1      |
|              |
|              |
|              |
|              |
+----------+---+
               |
               |    +------------+
               |    |            |
               |    |            |
               |    |            |
               +--->+  *Box 2*   |
                    |            |
                    |            |
                    |            |
                    +------------+

shows up in mdp with an ugly non-rectangular border:

image

Is there a way to format the input better? Or is it really a bug?

I think backspaces at the beginning of each line should work. Otherwise the preceeding spaces are recognized as code block.

dsyer commented

Sorry, I'm not following you. Backspaces are not part of a regular Markdown unless I missed something, so what do you mean exactly? Maybe you can paste me a version of that picture that renders cleanly or something?

Do you think we could keep the issue open until we have finished the conversation?

Of cause they are: https://daringfireball.net/projects/markdown/syntax#backslash

If you want to prevent something from beeing interpreted as markdown, you escape it with backslash. In your case "4 spaces at the beginning of a line" are interpreted as beginning of a code block, and you can prevent that by adding a backslash at the beginning of each line of your ascii art.

https://raw.githubusercontent.com/visit1985/mdp/master/sample.md

dsyer commented

Ah, so you said "backspace" when you meant "backslash". That makes more sense. But I'm not convinced really yet, because the whole block of asciiart is inside fences that you say in the sample.md should be interpreted as code block boundaries. Am I missing something still?

dsyer commented

This is what it looks like with backslashes:

image

So, I think you'll agree it's not right?

What do you meen with "the whole block of asciiart is inside fences"? Can you provide the markdown?

dsyer commented

Here:

Next Slide
==========

\~~~
+----------------------------+
|                            |
|                            |
|                            |
|       Box 1                |
|                            |
|                            |
|                            |
|                            |
+--------------+-------------+
               |
               |                     +------------------------------------+
               |                     |                                    |
               |                     |                                    |
               |                     |                                    |
               +-------------------->+         *Box 2*                    |
                                     |                                    |
                                     |                                    |
                                     |                                    |
                                     +------------------------------------+
\~~~

Of course the twiddle fences are not escaped with backslashes in my version (that's the only way I can persuade github to render them).

This seams to be a bug indeed. The width of the code block "window" is not calculated correctly when there are preceding spaces.

A simpler repro-case shows that this affects all code blocks not only fenced ones:

      this is code
      this is much longer code

As a workaround, you can do this (which does not use codeblocks):

\+---------+
\|         |
\|  Box 1  |
\|         |
\+---------+
\     |
\     |         +---------+
\     |         |         |
\     +-------->|  *Box 2*  |
\               |         |
\               +---------+
dsyer commented

Thanks for the workaround. I think it still calculates something wrong because the "Box 2" box is not straight edged at the right:

image

I do like the fact that it has a non-inverted background though. Can we have that as a feature too (optional for all code blocks, so asciiart looks better)?

dsyer commented

Possibly related (if it's not I'll open a new issue): empty lines in a code block switch off the inverted background, so you get "stripy" code snippets. Looks kind of ugly too. Example:

image

If you put even one space on each empty line the problem goes away (so that's a workaround, but I think it's probably a bug still).