forked from viennet/Referentiels
Conversion des URLs http(s) en markdown
This commit is contained in:
parent
3c2ffc1867
commit
32b8a1bb9b
@ -190,6 +190,7 @@ for sem in ressources:
|
|||||||
output = r.to_yaml()
|
output = r.to_yaml()
|
||||||
if WITH_EXPORT and r.code:
|
if WITH_EXPORT and r.code:
|
||||||
fichier = f"{args.outdir}/{r.code}.yml"
|
fichier = f"{args.outdir}/{r.code}.yml"
|
||||||
|
__LOGGER.warning(f"writing '{fichier}")
|
||||||
with open(fichier, "w", encoding="utf8") as fid:
|
with open(fichier, "w", encoding="utf8") as fid:
|
||||||
fid.write(output)
|
fid.write(output)
|
||||||
|
|
||||||
|
@ -150,6 +150,14 @@ class Docx():
|
|||||||
|
|
||||||
output = "\n".join(lignes_finales)
|
output = "\n".join(lignes_finales)
|
||||||
|
|
||||||
|
# Remplace http(s) URLs pour markdown
|
||||||
|
output = re.sub( r"(http(s)?://[\w\d:#@%/;~_?\+-=\\\.&]*)", r"[\1](\1)", output )
|
||||||
|
# Remplace les guillemets
|
||||||
|
# ne traite pas tous les cas, mais arrange la majorité
|
||||||
|
output = re.sub( r"\"(.*?)\"", r"«\1»", output, flags=re.DOTALL)
|
||||||
|
# On utilise les guillements français (ajout automatique des bons espaces)
|
||||||
|
output = output.replace("«", r"\og ").replace("»", r"\fg{}")
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
class RessourceDocx(Docx):
|
class RessourceDocx(Docx):
|
||||||
@ -284,6 +292,7 @@ class RessourceDocx(Docx):
|
|||||||
# Remet en forme le descriptif
|
# Remet en forme le descriptif
|
||||||
self.split_description()
|
self.split_description()
|
||||||
self.nettoie_contenu()
|
self.nettoie_contenu()
|
||||||
|
print(f"{self.code} {self.semestre}")
|
||||||
|
|
||||||
def to_yaml(self):
|
def to_yaml(self):
|
||||||
"""Exporte la ressource en yaml"""
|
"""Exporte la ressource en yaml"""
|
||||||
|
Loading…
Reference in New Issue
Block a user