terrastruct / d2-vscode

VSCode extension for D2 files.
https://d2lang.com
BSD 3-Clause "New" or "Revised" License
240 stars 11 forks source link

Opt-in footnotes in svg and connection tooltips #126

Open johannes-z opened 1 year ago

johannes-z commented 1 year ago

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"
gavin-ts commented 1 year ago

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)