forked from HEL/chronos
		
	removed useless invisible participants
This commit is contained in:
		| @@ -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 = () | ||||
|    | ||||
|   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 { | ||||
|      | ||||
|     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) | ||||
|  | ||||
|     if after.name in linked { | ||||
|       participants.push(after) | ||||
|     } | ||||
|   } | ||||
|   if "]" in linked { | ||||
|     participants.push(_par("]", invisible: true).first()) | ||||
|   } | ||||
|  | ||||
|   // Add index to participant | ||||
|   for (i, p) in participants.enumerate() { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user