d2-vscode icon indicating copy to clipboard operation
d2-vscode copied to clipboard

Opt-in footnotes in svg and connection tooltips

Open johannes-z opened this issue 2 years ago • 1 comments
trafficstars

Hi, I'm using the vscode extension for d2, writing in markdown and using d2 code blocks. It would be cool if there was an opt-in setting to print tooltips on shapes as footnotes, just like when exporting to pdf/png.

The flag could either be an option in d2, or a flag on the cli, e.g. --footnotes:

# variant 1
Hello: {
  tooltip: Tooltip from Shape "Hello"
  footnote: true
}

# variant 2
footnotes: true

Hello: {
  tooltip: Tooltip from Shape "Hello"
}

Additionally, tooltips on connections would also be nice. When they are converted to footnotes, they could be numbered/ordered using a, b and so on instead of numbers, and have an indent, similar to how lists work in markdown.

Example:

Hello -> World: {
  tooltip: Tooltip from Connection between Shapes "Hello" and "World"
}
Hello: {
  tooltip: Tooltip from Shape "Hello"
}
World: {
  tooltip: Tooltip from Shape "World"
}

Footnotes printed:

1. Tooltip from Shape "Hello"
  a. Tooltip from Connection between Shapes "Hello" and "World"
2. Tooltip from Shape "World"

johannes-z avatar Nov 07 '23 12:11 johannes-z

I think this can be achieved by adding a config setting to the extension for the --force-appendix flag.

      --force-appendix         $D2_FORCE_APPENDIX    an appendix for tooltips and links is added to PNG exports since they are not interactive. --force-appendix adds an appendix to SVG exports as well (default false)

gavin-ts avatar Nov 07 '23 18:11 gavin-ts