X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=build_readme.py;h=e082955a600c3f4dfabcdc835624748afc07bb30;hb=7b4791cfb73136db35160989c08660db55c3c34e;hp=eabed5850f989260c6a4115a424264e96d876fe1;hpb=940ccd88e7757e9bbb43288ed53a4ec4804bfbe8;p=perso%2FImmae%2FProjets%2FPython%2FMusicSampler.git diff --git a/build_readme.py b/build_readme.py index eabed58..e082955 100644 --- a/build_readme.py +++ b/build_readme.py @@ -1,13 +1,38 @@ import markdown +from markdown.extensions.toc import slugify -html = markdown.markdownFromFile( - input="documentation_fr.md", - extensions=['markdown.extensions.codehilite', 'markdown.extensions.toc'], +def lang_slugify(lang): + def l_slugify(value, separator): + return slugify(lang + "__" + value, separator) + return l_slugify + +def get_markdown(md_file, lang, table_of_content): + with open(md_file, "r") as f: + text = f.read() + + return markdown.markdown( + text=text, + extensions=[ + 'markdown.extensions.codehilite', + 'markdown.extensions.toc', + 'markdown.extensions.tables' + ], extension_configs={ 'markdown.extensions.codehilite': { 'noclasses': True, }, 'markdown.extensions.toc': { - 'title': 'Sommaire' + 'title': table_of_content, + 'slugify': lang_slugify(lang) } }) + + +print("

Documenation in english

") +print("

Documenation en Français

") +print("

Bottom of documentation

") +print("
") +print(get_markdown("documentation_en.md", "en", "Table of contents")) +print("
") +print(get_markdown("documentation_fr.md", "fr", "Sommaire")) +print("")