use init instead of cli & temporarily disable <multi> blocks supressing
This commit is contained in:
parent
8e8fd4aaf8
commit
b51ce330ee
@ -29,7 +29,7 @@ pymysql = "^1.0.3"
|
|||||||
peewee = "^3.16.2"
|
peewee = "^3.16.2"
|
||||||
|
|
||||||
[tool.poetry.scripts]
|
[tool.poetry.scripts]
|
||||||
spip2md = "spip2md.cli:main"
|
spip2md = "spip2md:main"
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["poetry-core"]
|
requires = ["poetry-core"]
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# SPIP website to plain Markdown files converter, Copyright (C) 2023 Guilhem Fauré
|
# SPIP website to plain Markdown files converter, Copyright (C) 2023 Guilhem Fauré
|
||||||
from spip2md.cli import main
|
from spip2md import main
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
@ -106,13 +106,6 @@ SPIP_TO_MARKDOWN = (
|
|||||||
),
|
),
|
||||||
"```\n\\1\n\n```",
|
"```\n\\1\n\n```",
|
||||||
),
|
),
|
||||||
( # WARNING Keep only the first language in multi-language blocks
|
|
||||||
compile(
|
|
||||||
r"<multi>\s*(?:\[.{2,4}\])?\s*(.*?)\s*(?:\s*\[.{2,4}\].*)*<\/multi>",
|
|
||||||
S | I,
|
|
||||||
),
|
|
||||||
r"\1",
|
|
||||||
),
|
|
||||||
( # WARNING remove every html tag
|
( # WARNING remove every html tag
|
||||||
compile(r"<\/?.*?>\s*", S | I),
|
compile(r"<\/?.*?>\s*", S | I),
|
||||||
r"",
|
r"",
|
||||||
@ -252,6 +245,12 @@ UNKNOWN_ISO = (
|
|||||||
r"∆",
|
r"∆",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Multi language block, capture the first
|
||||||
|
MULTILINGUAL = compile(
|
||||||
|
r"<multi>\s*(?:\[.{2,4}\])?\s*(.*?)\s*(?:\s*\[.{2,4}\].*)*<\/multi>",
|
||||||
|
S | I,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# Apply SPIP to Markdown & ISO to UTF conversions to a text, & eventually clean meta
|
# Apply SPIP to Markdown & ISO to UTF conversions to a text, & eventually clean meta
|
||||||
def convert(text: Optional[str], clean_meta: bool = False) -> str:
|
def convert(text: Optional[str], clean_meta: bool = False) -> str:
|
||||||
|
@ -84,7 +84,10 @@ class Document(SpipWritable, SpipDocuments):
|
|||||||
def filename(self, date: bool = False) -> str:
|
def filename(self, date: bool = False) -> str:
|
||||||
name_type: tuple[str, str] = splitext(basename(str(self.fichier)))
|
name_type: tuple[str, str] = splitext(basename(str(self.fichier)))
|
||||||
return (
|
return (
|
||||||
slugify((self.date_publication + "-" if date else "") + name_type[0])
|
slugify(
|
||||||
|
(self.date_publication + "-" if date else "") + name_type[0],
|
||||||
|
max_length=100,
|
||||||
|
)
|
||||||
+ name_type[1]
|
+ name_type[1]
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -161,7 +164,7 @@ class SpipObject(SpipWritable):
|
|||||||
def dir_slug(self, include_date: bool = False, end_slash: bool = True) -> str:
|
def dir_slug(self, include_date: bool = False, end_slash: bool = True) -> str:
|
||||||
date: str = self.date + "-" if include_date else ""
|
date: str = self.date + "-" if include_date else ""
|
||||||
slash: str = "/" if end_slash else ""
|
slash: str = "/" if end_slash else ""
|
||||||
return slugify(date + self.titre) + slash
|
return slugify(date + self.titre, max_length=100) + slash
|
||||||
|
|
||||||
# Get filename of this object
|
# Get filename of this object
|
||||||
def filename(self) -> str:
|
def filename(self) -> str:
|
||||||
|
Loading…
Reference in New Issue
Block a user