| 131 | } |
| 132 | |
| 133 | fn build_display_map( |
| 134 | body: &str, |
| 135 | registry_status: &HashMap<String, String>, |
| 136 | ) -> (HashMap<String, usize>, Vec<String>, usize) { |
| 137 | let mut display_map: HashMap<String, usize> = HashMap::new(); |
| 138 | let mut order: Vec<String> = Vec::new(); |
| 139 | let mut rejected_refs_in_body = 0usize; |
| 140 | |
| 141 | for m in CIT_ID_RE.find_iter(body) { |
| 142 | let cit_id = m.as_str(); |
| 143 | if display_map.contains_key(cit_id) { |
| 144 | continue; |
| 145 | } |
| 146 | if let Some(status) = registry_status.get(cit_id) { |
| 147 | if status == "REJECTED" { |
| 148 | rejected_refs_in_body += 1; |
| 149 | continue; |
| 150 | } |
| 151 | } |
| 152 | let n = order.len() + 1; |
| 153 | display_map.insert(cit_id.to_string(), n); |
| 154 | order.push(cit_id.to_string()); |
| 155 | } |
| 156 | |
| 157 | (display_map, order, rejected_refs_in_body) |
| 158 | } |
| 159 | |
| 160 | fn renumber_body(body: &str, display_map: &HashMap<String, usize>) -> String { |
| 161 | let pass1 = BRACKETED_GROUP_RE.replace_all(body, |caps: ®ex::Captures| { |