lowercase meta class (pyright) + do not print title in markdown & h1 headings
This commit is contained in:
parent
3a261800a6
commit
ca4a3c1a96
@ -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
|
||||
|
@ -2,18 +2,19 @@ import re
|
||||
|
||||
mappings = (
|
||||
# SPIP syntax to Markdown
|
||||
( # horizontal-rule
|
||||
( # horizontal rule
|
||||
re.compile(r"- ?- ?- ?- ?[\- ]*|<hr ?.*?>", re.S | re.I),
|
||||
# r"---",
|
||||
r"***",
|
||||
),
|
||||
( # line-break
|
||||
( # line break
|
||||
re.compile(r"\r?\n_ *(?=\r?\n)|<br ?.*?>", 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)",
|
||||
),
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user