release: unwrap the changelog for the Gitea release notes
CI / test (push) Successful in 48s

Gitea renders release notes with hard line breaks — a soft newline in the
body becomes a <br/> — so the changelog's ~80-column wrapping made every
bullet break mid-sentence on the release page. The AppStream path already
joined continuation lines before emitting <li>; the --notes path handed the
raw section to Gitea.

Join them there too, keeping blank lines, ATX headings, list items and fenced
code intact, and refresh the live v0.9.2 body with the fixed output.
This commit is contained in:
raucao committed 2026-12-01 14:04:20 +04:00
1 parent 44d12b0e7e
commit 3ac9b24d76
3 files changed
+74 -3

No files matched your search

+5 -1
View File
@@ -91,7 +91,11 @@ the UI is tested. `build-aux/deploy-dev.sh` runs on the build host,
`vercmp` both disagree with the semver spelling.
- **Release notes live only in `CHANGELOG.md`.** The metainfo `<releases>` block
is generated from it by `build-aux/gen-metainfo-releases.py` (between the
`releases:begin`/`releases:end` markers); never hand-edit the block.
`releases:begin`/`releases:end` markers); never hand-edit the block. The Gitea
release body is the same section, **unwrapped** by that script's `--notes`
path: Gitea renders release notes with hard line breaks, so the changelog's
~80-column wrapping would otherwise become a `<br/>` per line. Write the
changelog wrapped; the generator un-wraps it for the renderer.
- **The AUR recipes are `build-aux/aur/{regent,regent-git}`** — the stable
tarball package and the VCS one. `publish` fills `pkgver`/`_tag`, the real
sha256, and the signing fingerprint (`validpgpkeys`, with the `.asc` in
+64 -1
View File
@@ -16,6 +16,11 @@ Everything between the `releases:begin` / `releases:end` comments in the
template is replaced in place; everything else is left alone. The `[Unreleased]`
section and headings without a date are skipped. Run by build-aux/release.sh,
and safe to run by hand.
`--notes VERSION` prints one section as markdown, for the Gitea release body.
Gitea renders release notes with **hard** line breaks (a soft newline becomes a
`<br/>`), so that path unwraps the changelog's ~80-column wrapping into flowing
paragraphs; the AppStream path joins continuation lines itself.
"""
from __future__ import annotations
@@ -125,6 +130,64 @@ def extract_section(path: Path, version: str) -> str:
return "\n".join(body).strip()
def unwrap_markdown(text: str) -> str:
"""Join hard-wrapped lines so a renderer that turns newlines into breaks
(Gitea's release notes do) shows flowing paragraphs.
A blank line separates blocks; ATX headings and list items stand alone (a
bullet's own wrapped lines join it, the next bullet starts a new block);
fenced code is preserved verbatim; everything else joins with a space.
"""
blocks: list[str] = []
buf: list[str] = []
fence: str | None = None
def flush() -> None:
if buf:
blocks.append(" ".join(buf))
buf.clear()
for raw in text.splitlines():
stripped = raw.strip()
if fence is not None:
flush()
blocks.append(raw.rstrip())
if stripped.startswith(fence):
fence = None
continue
if stripped[:3] in ("```", "~~~"):
flush()
fence = stripped[:3]
blocks.append(stripped)
continue
if not stripped:
flush()
blocks.append("")
continue
if stripped.startswith("#"):
flush()
blocks.append(stripped)
continue
# A new bullet starts a block; an indented continuation of the previous
# one does not (BULLET is anchored, so it only matches column 0).
if BULLET.match(raw):
flush()
buf.append(stripped)
continue
buf.append(stripped)
flush()
# Collapse runs of blank lines and trim the ends.
out: list[str] = []
for block in blocks:
if block == "" and (not out or out[-1] == ""):
continue
out.append(block)
while out and out[-1] == "":
out.pop()
return "\n".join(out)
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("changelog", type=Path)
@@ -145,7 +208,7 @@ def main() -> int:
print(f"{args.changelog}: no section for {args.notes} (pre-release versions must match the heading)",
file=sys.stderr)
return 1
print(notes)
print(unwrap_markdown(notes))
return 0
if args.metainfo is None:
+5 -1
View File
@@ -85,7 +85,11 @@ Release notes live in `CHANGELOG.md` and nowhere else. Write the new section
under `## [Unreleased]` before releasing; `prepare` renames that heading to the
version and date. The AppStream release entries are generated from the same file
by `build-aux/gen-metainfo-releases.py` — do not edit the
`releases:begin`/`releases:end` block by hand.
`releases:begin`/`releases:end` block by hand. The Gitea release body is that
section too, and the generator **unwraps** it first: Gitea renders release notes
with hard line breaks, so the changelog's ~80-column wrapping would otherwise
become a `<br/>` per line. Keep the changelog wrapped for reading; the notes are
unwrapped for you.
## Skipping steps