diff --git a/spip2md/Metadata.py b/spip2md/Metadata.py index 3116e91..acba627 100644 --- a/spip2md/Metadata.py +++ b/spip2md/Metadata.py @@ -4,12 +4,12 @@ from slugify import slugify from SpipDatabase import * -class Metadata: +class metadata: def __init__(self, article): self.id = article.id_article # self.surtitle = article.surtitre # Probably unused - # self.title = self.clean(article.titre) - self.title = convert(article.titre) + self.title = "title" + # self.title = convert(article.titre) self.subtitle = article.soustitre # Probably unused # self.section = article.id_rubrique # TODO join self.description = convert(article.descriptif) @@ -62,7 +62,8 @@ class Metadata: # Contains things before the article like caption & titles def get_starting(self): return ( - f"{self.caption}\n" if len(self.caption) > 0 else "" + f"# {self.title}\n" + # f"{self.caption}\n" if len(self.caption) > 0 else "" + f"# {self.title}\n" + f"{self.caption}\n" if len(self.caption) > 0 else "" ) # Contains things after the article like ps & extra diff --git a/spip2md/convert.py b/spip2md/convert.py index b1cb1e6..f3eb001 100644 --- a/spip2md/convert.py +++ b/spip2md/convert.py @@ -2,18 +2,19 @@ import re mappings = ( # SPIP syntax to Markdown - ( # horizontal-rule + ( # horizontal rule re.compile(r"- ?- ?- ?- ?[\- ]*|
", re.S | re.I), # r"---", r"***", ), - ( # line-break + ( # line break re.compile(r"\r?\n_ *(?=\r?\n)|
", re.S | re.I), "\n", ), ( # heading re.compile(r"\{\{\{ *(.*?) *\}\}\}", re.S | re.I), - r"## \1", + r"# \1", + # r"## \1", ), ( # strong re.compile(r"\{\{ *(.*?) *\}\}", re.S | re.I), @@ -38,7 +39,7 @@ mappings = ( re.compile(r"<(?:img|image)(.*?)(\|.*?)*>", re.S | re.I), r"![image](\1)", ), - ( # document-anchors + ( # document anchor re.compile(r"<(?:doc|emb)(.*?)(\|.*?)*>", re.S | re.I), r"[document](\1)", ), diff --git a/spip2md/spip2md.py b/spip2md/spip2md.py index 6dd3b42..4742a4b 100755 --- a/spip2md/spip2md.py +++ b/spip2md/spip2md.py @@ -5,7 +5,7 @@ from shutil import rmtree from config import CONFIG from convert import convert -from Metadata import Metadata +from Metadata import metadata from SpipDatabase import * # Clean the output dir & create a new @@ -39,7 +39,7 @@ for exported in range(nbToExport): if exported > 0 and exported % 10 == 0: print(f"\n--- {nbToExport - exported} articles remaining ---\n") article = articles[exported] - meta = Metadata(article) + meta = metadata(article) print(f"{exported+1}. Exporting {meta.title}") print(f" to {meta.get_slug()}/index.md")