Return the multiset-ish fingerprints that must not change.
(body)
| 122 | |
| 123 | |
| 124 | def _invariants(body): |
| 125 | """Return the multiset-ish fingerprints that must not change.""" |
| 126 | return { |
| 127 | "code_spans": sorted(re.findall(r"`[^`]*`", body)), |
| 128 | "shortcodes": sorted(re.findall(r"\{\{[<%].*?[%>]\}\}", body, re.DOTALL)), |
| 129 | "links": sorted(re.findall(r"\]\([^)]*\)", body)), |
| 130 | "words": re.findall(r"\S+", body), # no word added/removed/reordered |
| 131 | } |
| 132 | |
| 133 | |
| 134 | def process_file(path, opts, counts): |