removed useless invisible participants

This commit is contained in:
Louis Heredero 2024-06-20 00:46:42 +02:00
parent 29787ad8f1
commit 3610c86884
Signed by: HEL
GPG Key ID: 8D83DE470F8544E7

View File

@ -10,6 +10,10 @@
}
#let diagram(elements) = {
if elements == none {
return
}
let participants = ()
let elmts = elements
let i = 0
@ -31,6 +35,7 @@
}
// List participants
let linked = ()
for elmt in elmts {
if elmt.type == "par" {
participants.push(elmt)
@ -42,24 +47,49 @@
let par = _par(elmt.p2, from-start: not elmt.create-dst).first()
participants.push(par)
}
if elmt.p1 == "?" {
linked.push("?" + elmt.p2)
} else {
linked.push(elmt.p1)
}
if elmt.p2 == "?" {
linked.push(elmt.p1 + "?")
} else {
linked.push(elmt.p2)
}
}
}
linked = linked.dedup()
let pars = participants
participants = ()
participants.push(_par("[", invisible: true).first())
if "[" in linked {
participants.push(_par("[", invisible: true).first())
}
for (i, p) in pars.enumerate() {
let before = _par("?" + p.name, invisible: true).first()
let after = _par(p.name + "?", invisible: true).first()
if i == 0 {
participants.push(before)
} else {
participants.insert(-1, before)
if before.name in linked {
if participants.len() == 0 or not participants.last().name.ends-with("?") {
participants.push(before)
} else {
participants.insert(-1, before)
}
}
participants.push(p)
participants.push(after)
if after.name in linked {
participants.push(after)
}
}
if "]" in linked {
participants.push(_par("]", invisible: true).first())
}
participants.push(_par("]", invisible: true).first())
// Add index to participant
for (i, p) in participants.enumerate() {