mirror of
https://forge.chapril.org/tykayn/orgmode-to-gemini-blog
synced 2025-06-20 09:04:42 +02:00
up detection of slug
This commit is contained in:
parent
618c029c62
commit
a0bb742d4c
46 changed files with 737 additions and 4848 deletions
23
utils.py
23
utils.py
|
@ -4,7 +4,6 @@ import re
|
|||
import shutil
|
||||
from datetime import datetime
|
||||
|
||||
import website_config
|
||||
from website_config import *
|
||||
|
||||
# this path should be customized
|
||||
|
@ -126,8 +125,8 @@ def get_files_list_of_folder(folder_path):
|
|||
# Liste les fichiers articles, trie par nom décroissant
|
||||
try:
|
||||
fichiers_md = sorted(
|
||||
[f.replace('.' + website_config['source_files_extension'], '.gmi') for f in os.listdir(folder_path) if
|
||||
f.endswith(website_config['source_files_extension'])], reverse=True)
|
||||
[f.replace('.' + global_config['source_files_extension'], '.gmi') for f in os.listdir(folder_path) if
|
||||
f.endswith(global_config['source_files_extension'])], reverse=True)
|
||||
print('fichiers trouvés:', len(fichiers_md))
|
||||
return fichiers_md
|
||||
except OSError as e:
|
||||
|
@ -182,3 +181,21 @@ def remove_hint_html(text):
|
|||
pattern = r"<p>ceci<sub>estduhtml</sub></p>"
|
||||
replacement = ""
|
||||
return re.sub(pattern, replacement, text, flags=re.DOTALL)
|
||||
|
||||
|
||||
def detect_slug_in_file_basename(file_basename):
|
||||
"""
|
||||
Extrait l'année et le slug du nom de fichier selon le format spécifié.
|
||||
|
||||
:param file_basename: Nom de fichier (str).
|
||||
:return: Tuple contenant l'année et le slug (année, slug) ou None si non trouvé.
|
||||
"""
|
||||
pattern = r'^(\d{4})\d{8}(.+)\.org$'
|
||||
match = re.match(pattern, file_basename)
|
||||
if match:
|
||||
year = match.group(1)
|
||||
slug = match.group(2)
|
||||
|
||||
final_slug = f"{year}/{slug}"
|
||||
return final_slug
|
||||
return None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue