From c6c9d6a415835c6ad2878de1b6d4c9da79db8aa0 Mon Sep 17 00:00:00 2001 From: Andreas Zweili Date: Mon, 9 Nov 2020 12:43:52 +0100 Subject: [PATCH] remove special characters from the titles --- url2markdown/file.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/url2markdown/file.py b/url2markdown/file.py index 01c7a3e..f8009c4 100644 --- a/url2markdown/file.py +++ b/url2markdown/file.py @@ -2,9 +2,18 @@ import os.path import markdownify +def _clean_title(raw_title): + title = str(raw_title) + bad_characters = ['«', '»', ',', '.', "'", "`", + "?", "’", "{", "}", "(", ")", "[", "]", "!", "$"] + for character in bad_characters: + title = title.replace(character, '') + return title + + def _build_path(title): ressources_folder = "~/03_documents/ressources/articles/" - base_filename = str(title) + base_filename = _clean_title(title) short_path = os.path.join(ressources_folder, base_filename + ".md") return os.path.expanduser(short_path)