fix(changelog): make every surface split a release the same way

The app, the website and the release scripts each parse CHANGELOG.md with
their own code, and only the app skipped fenced code blocks and read CRLF.
A `###` or a release heading inside a fenced example in a highlight would
have ended the highlights early on the website and in the GitHub release
body, or started a phantom release, while the app showed it correctly.

The website and script parsers now follow the app's rules, and one case
file, scripts/test-support/changelog-structure.json, is run by all three
suites so a rule cannot change in one place only.

The release-notes script tests were not part of any CI job; they now run
with the other script contract tests.
This commit is contained in:
Mohamed Boudra
2026-11-10 10:04:33 +01:00
parent eda939b092
commit ccdca942e9
8 changed files with 361 additions and 16 deletions
@@ -0,0 +1,167 @@
{
"document": [
"# Changelog",
"",
"Text above the first release belongs to no release.",
"",
"## 4.0.0 - 2026-04-04",
"",
"- **First highlight:** One sentence. A second one. ([#1](https://example.com/1))",
"- **Nested content:** A highlight with a nested list.",
" - Nested item",
"",
" A second paragraph inside the item.",
"",
"- **Markdown example:** A fenced block whose contents look like headings.",
"",
" ```markdown",
" ## 9.9.9 - 2026-09-09",
" ### Not a section",
" ```",
"",
"```",
"## 9.9.8 - 2026-09-08",
"### Not a section either",
"```",
"",
"#### A deeper heading is not a section",
"",
"###Unspaced hashes are text",
"",
"### Added ",
"",
"- Added a thing ([#2](https://example.com/2))",
"",
"#### A sub-heading stays in its section",
"",
"~~~~",
"### Still code",
"~~~",
"## 9.9.7 - 2026-09-07",
"~~~~",
"",
"###\tChanged",
"",
"- Changed a thing",
"",
"### 修复",
"",
"- 修复了一个问题",
"",
"## 3.0.0 - 2026-03-03",
"",
"### Fixed",
"",
"- Fixed one thing",
"",
"## 3.0.0-beta.1 - 2026-03-01",
"",
"> **Notice**",
">",
"> A quoted notice opens this entry.",
"",
"A summary paragraph follows it.",
"",
"### Added",
"",
"- Added another thing",
"",
"## 2.0.0 - 2026-02-02",
"",
"- **Only a highlight:** No sections follow.",
"",
"## 1.0.0 - 2026-01-01",
"",
"Text before a heading with no title.",
"",
"###",
"",
"- The first section has no title",
""
],
"releases": [
{
"version": "4.0.0",
"date": "2026-04-04",
"highlights": [
"- **First highlight:** One sentence. A second one. ([#1](https://example.com/1))",
"- **Nested content:** A highlight with a nested list.",
" - Nested item",
"",
" A second paragraph inside the item.",
"",
"- **Markdown example:** A fenced block whose contents look like headings.",
"",
" ```markdown",
" ## 9.9.9 - 2026-09-09",
" ### Not a section",
" ```",
"",
"```",
"## 9.9.8 - 2026-09-08",
"### Not a section either",
"```",
"",
"#### A deeper heading is not a section",
"",
"###Unspaced hashes are text"
],
"sections": [
"### Added ",
"",
"- Added a thing ([#2](https://example.com/2))",
"",
"#### A sub-heading stays in its section",
"",
"~~~~",
"### Still code",
"~~~",
"## 9.9.7 - 2026-09-07",
"~~~~",
"",
"###\tChanged",
"",
"- Changed a thing",
"",
"### 修复",
"",
"- 修复了一个问题"
],
"sectionTitles": ["Added", "Changed", "修复"]
},
{
"version": "3.0.0",
"date": "2026-03-03",
"highlights": [],
"sections": ["### Fixed", "", "- Fixed one thing"],
"sectionTitles": ["Fixed"]
},
{
"version": "3.0.0-beta.1",
"date": "2026-03-01",
"highlights": [
"> **Notice**",
">",
"> A quoted notice opens this entry.",
"",
"A summary paragraph follows it."
],
"sections": ["### Added", "", "- Added another thing"],
"sectionTitles": ["Added"]
},
{
"version": "2.0.0",
"date": "2026-02-02",
"highlights": ["- **Only a highlight:** No sections follow."],
"sections": [],
"sectionTitles": []
},
{
"version": "1.0.0",
"date": "2026-01-01",
"highlights": ["Text before a heading with no title."],
"sections": ["###", "", "- The first section has no title"],
"sectionTitles": [""]
}
]
}