d2 icon indicating copy to clipboard operation
d2 copied to clipboard

Near keyword does not work

Open pleshevskiy opened this issue 3 years ago • 1 comments

Seems like near keyword in text block does not work. And we have to reorder block manually, but reordering doesn't work too in complex examples. See below.

Simple

If we want to render text near to a block or group

a; b; c; d;

foo: |txt
bar biz baz
| {
  near: b
}

Expected

[a] [b] [c] [d]
   ↑ or↑
   `foo`

Actual

image

Workaround

We can reorder the text block and now it works as expected without near keyword.

a; b;

foo: |txt
bar biz baz
|

c; d;

image

Complex

if we want to render text near to a connected block or group

a -> e; b -> f;

foo: |txt
bar biz baz
| {
  near: b
}

c -> g; d -> h;

Expected

   `foo`
   ↓ or↓
[a] [b] [c] [d]
 ↓   ↓   ↓   ↓
[e] [f] [g] [h]

Actual

image

Misc

Tested on d2 versions 0.0.13 and latest e6c7d066164040098d294c00779a2248c402c864

pleshevskiy avatar Nov 30 '22 10:11 pleshevskiy

it does not, sorry for the lack of clarity. i have it in the next release of d2-docs to document that:

https://github.com/terrastruct/d2-docs/pull/15/files#diff-d23c28129c5e819c092f20bfcbf291203169d455eabed54a3498779040e06b20R123

we'll add support for it probably in the release after

alixander avatar Nov 30 '22 17:11 alixander

Also, it seems near only "works" with top-level shapes. Otherwise, it gives a "failed to recompile" error and a panic dump, for example:

dog.flea
comment: |md
    parasite
| {
    near: dog.flea
}

murphyke avatar Dec 22 '22 21:12 murphyke

documented

alixander avatar May 01 '23 23:05 alixander