forked from HEL/chronos
		
	removed useless invisible participants
This commit is contained in:
		| @@ -10,6 +10,10 @@ | |||||||
| } | } | ||||||
|  |  | ||||||
| #let diagram(elements) = { | #let diagram(elements) = { | ||||||
|  |   if elements == none { | ||||||
|  |     return | ||||||
|  |   } | ||||||
|  |    | ||||||
|   let participants = () |   let participants = () | ||||||
|   let elmts = elements |   let elmts = elements | ||||||
|   let i = 0 |   let i = 0 | ||||||
| @@ -31,6 +35,7 @@ | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   // List participants |   // List participants | ||||||
|  |   let linked = () | ||||||
|   for elmt in elmts { |   for elmt in elmts { | ||||||
|     if elmt.type == "par" { |     if elmt.type == "par" { | ||||||
|       participants.push(elmt) |       participants.push(elmt) | ||||||
| @@ -42,24 +47,49 @@ | |||||||
|         let par = _par(elmt.p2, from-start: not elmt.create-dst).first() |         let par = _par(elmt.p2, from-start: not elmt.create-dst).first() | ||||||
|         participants.push(par) |         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 |   let pars = participants | ||||||
|   participants = () |   participants = () | ||||||
|   participants.push(_par("[", invisible: true).first()) |    | ||||||
|  |   if "[" in linked { | ||||||
|  |     participants.push(_par("[", invisible: true).first()) | ||||||
|  |   } | ||||||
|  |    | ||||||
|   for (i, p) in pars.enumerate() { |   for (i, p) in pars.enumerate() { | ||||||
|     let before = _par("?" + p.name, invisible: true).first() |     let before = _par("?" + p.name, invisible: true).first() | ||||||
|     let after = _par(p.name + "?", invisible: true).first() |     let after = _par(p.name + "?", invisible: true).first() | ||||||
|     if i == 0 { |      | ||||||
|       participants.push(before) |     if before.name in linked { | ||||||
|     } else { |       if participants.len() == 0 or not participants.last().name.ends-with("?") { | ||||||
|       participants.insert(-1, before) |         participants.push(before) | ||||||
|  |       } else { | ||||||
|  |         participants.insert(-1, before) | ||||||
|  |       } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     participants.push(p) |     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 |   // Add index to participant | ||||||
|   for (i, p) in participants.enumerate() { |   for (i, p) in participants.enumerate() { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user