Skip to content

Commit

Permalink
Drop ":" before "Level" to compute short and series titles (#1677)
Browse files Browse the repository at this point in the history
Via #1676. The "Privacy-Preserving Attribution" spec separates the main title
and the level with a `:`, which wasn't handled as part of the logic used to
shorten the title.
  • Loading branch information
tidoust authored Feb 5, 2025
1 parent 7d5fafd commit 93f09de
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/build-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ async function runInfo(specs) {
else if (!res.series.title) {
res.series.title = res.title
.replace(/ \d+(\.\d+)?$/, '') // Drop level number
.replace(/( -)? Level$/, '') // Drop "Level"
.replace(/(:| -)? Level$/, '') // Drop "Level"
.replace(/ Module$/, '') // Drop "Module"
.replace(/^(RDF|SPARQL) \d\.\d/, '$1'); // Handle RDF/SPARQL titles
}
Expand Down
2 changes: 1 addition & 1 deletion src/compute-shorttitle.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default function (title) {
.trim()
.replace(/\s/g, ' ') // Replace non-breaking spaces
.replace(/ \d+(\.\d+)?$/, '') // Drop level number for now
.replace(/( -)? Level$/i, '') // Drop "Level"
.replace(/(:| -)? Level$/i, '') // Drop "Level"
.replace(/ \(\v\d+(\.\d+)?\)/i, '') // Drop "(vx.y)"
.replace(/\(Draft\)/i, '') // Drop "(Draft)" indication
.replace(/ Module$/i, '') // Drop "Module" (now followed by level)
Expand Down
6 changes: 6 additions & 0 deletions test/compute-shorttitle.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ describe("compute-shorttitle module", () => {
"Foo 2");
});

it("drops ': Level' from title", () => {
assertTitle(
"Foo: Level 7",
"Foo 7");
});

it("drops 'Module - Level' from title", () => {
assertTitle(
"Foo Module - Level 3",
Expand Down

0 comments on commit 93f09de

Please sign in to comment.