From 74aeb8474c05d198b7f5e7dcf3d64611b6cab6d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guilhem=20Faur=C3=A9?= Date: Wed, 24 May 2023 13:46:03 +0200 Subject: [PATCH] replace internal links --- spip2md/spipobjects.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spip2md/spipobjects.py b/spip2md/spipobjects.py index 7fe8d3c..f7d5338 100644 --- a/spip2md/spipobjects.py +++ b/spip2md/spipobjects.py @@ -1,4 +1,5 @@ from os.path import basename, splitext +from re import I, S, compile from peewee import ModelSelect from slugify import slugify @@ -16,6 +17,13 @@ from database import ( EXPORTTYPE: str = "md" +ARTICLE_LINK = compile(r"<(art|article)([0-9]+)(\|.*?)*>", S | I) + + +def link_articles(text: str): + for match in ARTICLE_LINK.findall(text): + article = Article.select().where(Article.id_article == match[0]) + class Document(SpipDocuments): class Meta: