Skip to content

Commit d920d99

Browse files
committed
exporter.py: slugify page titles in JSON and file names
It _should_ be impossible for non-slugified page titles to ened up in the database, but I found a few in my own collection. I can't seem to reproduce creating pages with these titles so my guess is that they came from an earlier verison of Silicon before slugification was as strict as it is now.
1 parent 0a8dd21 commit d920d99

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

silicon/exporter.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from silicon.page import get_titles, history, read
88
from silicon.related import get as get_related
9+
from silicon.util import slugify_title
910

1011

1112
def export_db(verbose):
@@ -39,7 +40,7 @@ def export_page(title):
3940
Export a single page as a dictionary.
4041
"""
4142
page = {}
42-
page['title'] = title
43+
page['title'] = slugify_title(title)
4344

4445
# get attributes
4546
page['attributes'] = {}
@@ -66,7 +67,7 @@ def export_page(title):
6667
# write each page dict to a JSON file
6768
for title_row in get_titles():
6869
title = title_row['title']
69-
export_file_path = export_dir / f"{title}.json"
70+
export_file_path = export_dir / f"{slugify_title(title)}.json"
7071

7172
with export_file_path.open('w', encoding='utf-8') as f:
7273
json.dump(export_page(title), f, ensure_ascii=False, indent=4)

0 commit comments

Comments
 (0)