From 765b5e93ea84ea830f60b8f434cb3e002a5f481e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guilhem=20Faur=C3=A9?= Date: Tue, 30 May 2023 17:51:44 +0200 Subject: [PATCH] add sections links regex --- spip2md/regexmap.py | 6 +++++- spip2md/spipobjects.py | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/spip2md/regexmap.py b/spip2md/regexmap.py index 56c9bf3..bd1c453 100644 --- a/spip2md/regexmap.py +++ b/spip2md/regexmap.py @@ -150,10 +150,14 @@ ARTICLE_LINK = ( ) # Name and path can be further replaced with .format() SECTION_LINK = ( - ( # SPIP style documents & embeds links + ( # SPIP style sections embeds compile(r"<()(?:rub|rubrique)([0-9]+)(?:\|(.*?))?>", S | I), r"[{}]({})", ), + ( # SPIP style sections links + compile(r"\[ *([^\]]*?) *-> *(?:rub|rubrique)([0-9]+) *\]", S | I), + r"[{}]({})", + ), ( # Markdown style internal links compile(r"\[(.*?)\]\((?:rub|rubrique)([0-9]+)(?:\|(.*?))?\)", S | I), r"[{}]({})", diff --git a/spip2md/spipobjects.py b/spip2md/spipobjects.py index c17fbf6..3586036 100644 --- a/spip2md/spipobjects.py +++ b/spip2md/spipobjects.py @@ -232,7 +232,7 @@ class SpipObject(SpipWritable): repl: str = path_link.format(match.group(1), doc.filename()) else: repl: str = path_link.format(doc.titre, doc.filename()) - logging.warn(f"Translating link to {repl}") + logging.info(f"Translating link to {repl}") return text.replace(match.group(), repl) def not_found_warn(path_link: str, text: str, match: Match) -> str: @@ -242,7 +242,7 @@ class SpipObject(SpipWritable): for id_link, path_link in DOCUMENT_LINK: # print(f"Looking for links like {id_link}") for match in id_link.finditer(text): - logging.warning(f"Found document link {match.group()} in {self.titre}") + logging.info(f"Found document link {match.group()} in {self.titre}") try: doc: Document = Document.get(Document.id_document == match.group(2)) text = found_replace(path_link, doc, text, match)