"""Print a version's CHANGELOG.md section as plain text for the Comfy Registry. The registry shows a version's changelog as one paragraph: line breaks and Markdown are not rendered. So headings become "Added:", "Fixed:"..., list items are joined with "; ", and Markdown markup is dropped. python .github/scripts/registry_changelog.py 1.2.2 python .github/scripts/registry_changelog.py --all # JSON {version: text} """ import json import re import sys def sections(path="CHANGELOG.md"): out, current = {}, None for line in open(path, encoding="utf-8").read().splitlines(): m = re.match(r"^## (\d+\.\d+\.\d+)\b", line) if m: current = m.group(1) out[current] = [] elif line.startswith("## "): current = None elif current: out[current].append(line) return out def plain(text): text = re.sub(r"\[([^\]]+)\]\([^)]+\)", r"\1", text) # links: keep the text text = re.sub(r"\*\*([^*]+)\*\*", r"\1", text) text = re.sub(r"(?