Skip to main content
8 of 11
Inlining allows reuse.
doug
  • 1.4k
  • 3
  • 9

K (ngn/k), 337 331 315 290 279 231 bytes

{t:@["|-"{1=x|-x}d;(-1+&~^l;!#y);:;("..''"(~^:)#l:s?*/1(~=':)\d:-':i:0,+\(s:,/-:\1,w:-1+2*x)4!2_&,/+|1(2*1+)\|!x;y:,/((#l)#("-";"")){x/y}',''l:(0,((#y)>)#+\(0,(-1+#l)#-1 1)+l:1_|1+&x#2)_y)];(x,w)#@[(x*w)#" ";(i;*|i);:;(t;"<>"2!x)]}

Try it online! -6 : Save a few bytes with shorter names.
-16 : Tidying up
-25 : Cruft
-46 : Golfing gets me back under limits

doug
  • 1.4k
  • 3
  • 9