stathissideris / ditaa

ditaa is a small command-line utility that can convert diagrams drawn using ascii art ('drawings' that contain characters that resemble lines like | / - ), into proper bitmap graphics.
GNU Lesser General Public License v3.0
927 stars 87 forks source link

escaping of characters in text boxes #9

Closed fommil closed 5 years ago

fommil commented 9 years ago

I would like to have a box containing text like :key but the colon is being stripped and sometimes gets interpreted as a dotted line indicator and "infects" the entire box.

stathissideris commented 9 years ago

Aaah, escaping... the second most requested feature after SVG output. Infecting the box is a feature that allows changing only one character to change the rendering for the whole box.

About escaping: Say I implement escaping using the \ character. I then get the problem of distinguishing escaping from rounded corners. So maybe I could escape things using an unusual character, like #. Fair enough. But then you have the problem of alignment: how much space does the espacing character occupy? There are two options:

The escaping character is zero-space

In order to get a box that contains the text :key you would have to type this

   +------+
   | #:key |
   +------+

This will render as such:

   +------+
   | :key |
   +------+

So the # is not rendered and it occupies zero space, which means that the final rendering does not have any unnecessary space, but the "source" of the diargam is broken and potentially unreadable in more complex cases (consider more shapes on the right of the box).

The escaping character takes up one space

For the previous example, you'd have to write this:

   +-------+
   | #:key |
   +-------+

This will render as:

   +-------+
   |  :key |
   +-------+

So the source is readable, but the rendered result looks awkward because it's not centered and there is a bit of space in the grid cell where the escaping character used to be.

Looking at my little essay, I think option 2 is probably preferable, but I still think that both make the syntax a bit weird.

fommil commented 9 years ago

option 2, because the rendering of size/alignment is a bit funky anyway.

It would of course be better if you could automatically detect that a character (e.g. colon) is not relevant when in a box.

stathissideris commented 9 years ago

Hm, the problem is because of the decision of considering -, |, = and : as short lines with a length of 1. Maybe that's a very uncommon case and they should be interpreted differently. That's option 3 I guess...

ewoutvonk commented 8 years ago

Instead of escaping, you could also look at the context. Your examples on http://ditaa.sourceforge.net/ always show whitespace between borders and actual text, if the character encountered is surrounded left and right by either whitespace or another line character ( -, |, =, : ), convert it, if it is surrounded by a word character on at least one side (directly adjacent), don't convert it. For English texts, you can just look at the left and right sides (it would be a different story for Chinese for example, where you would need to look up and down).

At this moment, it's impossible to put URLs in diagrams for example..

pihentagy commented 8 years ago

Also ran into escaping issues. Then how can I write commands literally? Dashes seems to be too clever:

git rm -r --cached .

So as I understand, there is no workaround yet, right?

rigidus commented 6 years ago

I would also like to escape characters interpreted as arrows:

+----+
|    |<------- \>CFA converts it to a pointer to this
+----+

Here ">CFA" is a Forth operation

trinitronx commented 6 years ago

Just a tip for those looking for the ability to just display a colon or other characters. Check the UTF-8 codepages for alternate character codes that look similar to the one you want.

For example, there is another alternate colon:

꞉
MODIFIER LETTER COLON
Unicode: U+A789, UTF-8: EA 9E 89

Edit: Yes, this is a sad workaround to avoid the issue with not being able to escape the characters ditaa treats as special.

chai2010 commented 6 years ago

https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms

maybe the full width characters is better choice

behrangsa commented 5 years ago

@stathissideris why did this get closed? Did this feature get implemented?

fommil commented 5 years ago

Create a new ticket if you want to work on this. I am no longer creating tickets unless I plan to work on them myself.

JuergenPurtz commented 5 years ago

Why is this issue closed? ditaa's 'key characters' like : or = are often used in texts and formulas, which is impossible at the moment (v 0.11). Please re-open it.

b00ga commented 5 years ago

Just wanted to thank @trinitronx for the Unicode workaround in this thread. I just started using ditaa and ran into the same dash issue as the OP in #19. Used Unicode hyphen, U+2010, and got my desired output.