chore(release): v1.4.24

Version bumped in both places that carry it - manifest.json is what
Thunderstore ships, PluginVersion is what the game logs - since those two have
drifted apart before.

The Nexus description is generated now rather than rewritten by hand. It had
fallen thirteen versions behind the README, which is how a hand-maintained
copy of a 72KB document goes. scripts/nexus-readme.py converts README.md to
the BBCode the page wants, following what the 1.4.11 page did by hand so the
two are comparable, and writes dist/NEXUS_README_<version>.bbcode.txt.

The wiki link was on the Nexus page and had never been in the README, so every
other channel shipped without it. It is in the README now, which means it
reaches Nexus, Thunderstore and the repository from one place.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
kanym 2026-09-26 01:45:08 +02:00
commit 421bc72eb7
4 changed files with 117 additions and 2 deletions

105
scripts/nexus-readme.py Normal file
View file

@ -0,0 +1,105 @@
"""Turns the mod's README.md into the BBCode Nexus wants.
The Nexus page had been rewritten by hand each release and had fallen thirteen
versions behind the README, so it is generated now. Run it after the changelog
entry is in and the version is bumped:
python scripts/nexus-readme.py
It reads manifest.json for the version and writes
dist/NEXUS_README_<version>.bbcode.txt.
The conversion follows what the 1.4.11 page did by hand, so the two are
comparable: headings become sized bold, a horizontal rule goes above every
top-level section, images are gathered onto one line per group, backticks
become quotes because Nexus has no code style, and the <details> wrappers
around the progressions are dropped while their summaries survive as headings.
"""
import json
import pathlib
import re
ROOT = pathlib.Path(__file__).resolve().parent.parent
RULE = "[s]---------------------------------------------------[/s]"
def inline(text):
"""Markdown's inline marks, in an order where they cannot eat each other."""
text = re.sub(r"\*\*(.+?)\*\*", r"[b]\1[/b]", text)
text = re.sub(r"`([^`]+)`", r'"\1"', text)
# An in-page anchor means nothing on a Nexus description, so the link text stays and the
# link goes: "Full details under Sverm" reads the same, and a dead #10-sverm does not.
text = re.sub(r"\[([^\]]+)\]\(#[^)]*\)", r"\1", text)
text = re.sub(r"\[([^\]]+)\]\(([^)]+)\)", r"[url=\2]\1[/url]", text)
return text
def image(url):
# The march gif is a strip rather than a portrait, and was shown smaller by hand.
return f"[img height={200 if 'small' in url else 350}]{url}[/img]"
def table_row(line):
cells = [inline(c.strip()) for c in line.strip().strip("|").split("|")]
if not cells:
return None
return "- [b]" + cells[0] + "[/b]" + ("" if len(cells) == 1 else " — " + " — ".join(cells[1:]))
def convert(markdown):
out = []
pending_images = []
def flush_images():
if pending_images:
out.append("".join(pending_images))
pending_images.clear()
for line in markdown.splitlines():
stripped = line.strip()
# Images stack up so a group of them lands on one line, the way Nexus shows them.
match = re.fullmatch(r"!\[[^\]]*\]\(([^)]+)\)", stripped)
if match:
pending_images.append(image(match.group(1)))
continue
flush_images()
if not stripped or stripped in ("<details>", "</details>", "---"):
continue
match = re.fullmatch(r"<summary><strong>(.+?)</strong></summary>", stripped)
if match:
out.append(f"[size=4][b]{inline(match.group(1))}[/b][/size]")
continue
match = re.fullmatch(r"(#{1,3})\s+(.*)", stripped)
if match:
level, title = len(match.group(1)), inline(match.group(2))
if level == 2:
out.append(RULE)
out.append(f"[size={7 - level}][b]{title}[/b][/size]")
continue
if stripped.startswith("|"):
if re.fullmatch(r"\|[\s\-:|]+\|", stripped): # the --- separator row
continue
row = table_row(stripped)
if row:
out.append(row)
continue
out.append(inline(stripped))
flush_images()
return "\n".join(out) + "\n"
def main():
version = json.loads((ROOT / "manifest.json").read_text(encoding="utf-8-sig"))["version_number"]
target = ROOT / "dist" / f"NEXUS_README_{version}.bbcode.txt"
target.write_text(convert((ROOT / "README.md").read_text(encoding="utf-8-sig")), encoding="utf-8")
print(f"{target.relative_to(ROOT)} ({len(target.read_text(encoding='utf-8').splitlines())} lines)")
main()