d2 icon indicating copy to clipboard operation
d2 copied to clipboard

markdown: Tables

Open alixander opened this issue 2 years ago • 2 comments

Currently tables within markdown are not supported. Need to hand-measure these https://github.com/terrastruct/d2/blob/master/d2renderers/textmeasure/markdown.go

alixander avatar Nov 22 '22 22:11 alixander

sql_table shape won't suffice because it doesn't support multiple columns

alixander avatar Nov 22 '22 22:11 alixander

https://discord.com/channels/1039184639652265985/1039184640285610147/1054867819256361060

alixander avatar Dec 20 '22 21:12 alixander

perhaps d2 should have a native shape type for this. sql_table_data. seems quite common in practice for people to want to show a sample

alixander avatar Mar 11 '23 16:03 alixander

I would name it not sql_data_table because it could be handy to use it for multiple purpose. But I would be happy to see something like this!!

jfudickar avatar Apr 11 '23 10:04 jfudickar

ohhh wait, we can just use grid with 0 gap for these! @gavin-ts . that'd be a great use case

https://github.com/terrastruct/d2/pull/1178

alixander avatar Apr 11 '23 18:04 alixander

that could work but it might be tricky to fit it into other markdown elements. I wonder why it isn't currently working, we may just need to update the measurement logic to consider tables correctly

to be clear, for this issue I think we are talking about:

| Syntax      | Description |
| ----------- | ----------- |
| Header      | Title       |
| Paragraph   | Text        |

producing:

Syntax Description
Header Title
Paragraph Text

gavin-ts avatar Apr 11 '23 18:04 gavin-ts

no i was just talking about representing tables in general. if we have such an option natively in D2, there's no need or a much lower priority to support it in markdown

alixander avatar Apr 11 '23 19:04 alixander

oh okay that makes sense with the comment about having a native shape for tables

I think a gap: 0 grid with rows and columns specified does indeed cover the table scenario

gavin-ts avatar Apr 11 '23 19:04 gavin-ts

I want to draw diagrams similar to this: Sample

Currently I'm using PlantUML but I'm thinking of having an additional option using D2.

https://github.com/jfudickar/json2puml

jfudickar avatar Apr 12 '23 08:04 jfudickar

https://play.d2lang.com/?l=&script=yk3NzbeqyU3hsilJTMpJteOyKSmysylJsUvLz09KLLLRL0mxs9EvKbLjstGHqqjh4gIEAAD__w%3D%3D&

bo-ku-ra avatar May 19 '23 10:05 bo-ku-ra