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.py | changed |
generator/parse_content.py | ||
---|---|---|
@@ -18,8 +18,12 @@ | ||
18 | 18 … | .lower(), |
19 | 19 … | ) |
20 | 20 … | |
21 | 21 … | |
22 … | +def sortable_title(string): | |
23 … | + return re.sub(r"^the ", "", string, flags=re.IGNORECASE).lower() | |
24 … | + | |
25 … | + | |
22 | 26 … | def parse_entry_data(entry_data): |
23 | 27 … | entry_data["date"] = datetime.datetime.fromisoformat(entry_data["date"] + "+00:00") |
24 | 28 … | if "description" in entry_data: |
25 | 29 … | entry_data["description"] = entry_data["description"].strip() |
@@ -71,9 +75,9 @@ | ||
71 | 75 … | if "series" in entry_data and slugify(entry_data["series"]) not in map( |
72 | 76 … | slugify, series |
73 | 77 … | ): |
74 | 78 … | series += [entry_data["series"].strip()] |
75 | - return sorted(series, key=str.lower) | |
79 … | + return sorted(series, key=sortable_title) | |
76 | 80 … | |
77 | 81 … | |
78 | 82 … | series = _series() |
79 | 83 … | |
@@ -86,9 +90,9 @@ | ||
86 | 90 … | tag.strip() |
87 | 91 … | for tag in entry_data["tags"] |
88 | 92 … | if slugify(tag) not in map(slugify, tags) |
89 | 93 … | ] |
90 | - return sorted(tags, key=str.lower) | |
94 … | + return sorted(tags, key=sortable_title) | |
91 | 95 … | |
92 | 96 … | |
93 | 97 … | tags = _tags() |
94 | 98 … |
Built with git-ssb-web