git ssb

0+

Grey the earthling / gkn.me.uk



Commit 892436b0a7a15cc521c1b6cbc0a37020b365bb39

Sort alphabetically more conventionally

Strip leading "The" from series and tags.
Grey Nicholson committed on 7/12/2023, 9:51:25 PM
Parent: 743afdfcf9384f8652fd5740f5a1550fd4f3eaeb

Files changed

generator/parse_content.pychanged
generator/parse_content.pyView
@@ -18,8 +18,12 @@
1818 .lower(),
1919 )
2020
2121
22 +def sortable_title(string):
23 + return re.sub(r"^the ", "", string, flags=re.IGNORECASE).lower()
24 +
25 +
2226 def parse_entry_data(entry_data):
2327 entry_data["date"] = datetime.datetime.fromisoformat(entry_data["date"] + "+00:00")
2428 if "description" in entry_data:
2529 entry_data["description"] = entry_data["description"].strip()
@@ -71,9 +75,9 @@
7175 if "series" in entry_data and slugify(entry_data["series"]) not in map(
7276 slugify, series
7377 ):
7478 series += [entry_data["series"].strip()]
75- return sorted(series, key=str.lower)
79 + return sorted(series, key=sortable_title)
7680
7781
7882 series = _series()
7983
@@ -86,9 +90,9 @@
8690 tag.strip()
8791 for tag in entry_data["tags"]
8892 if slugify(tag) not in map(slugify, tags)
8993 ]
90- return sorted(tags, key=str.lower)
94 + return sorted(tags, key=sortable_title)
9195
9296
9397 tags = _tags()
9498

Built with git-ssb-web