X-Git-Url: https://git.immae.eu/?p=perso%2FImmae%2FProjets%2FPython%2FMusicSampler.git;a=blobdiff_plain;f=build_readme.py;h=9f33dbd6740a10aa137685d1ac75013898081322;hp=655e00136a786897bd117f070c3c3f819a02f4f9;hb=faed2fa84ff988067532ae880df1ca00efb6a993;hpb=814c30c6835b25d06977af1dd2d1e565c45121cc diff --git a/build_readme.py b/build_readme.py index 655e001..9f33dbd 100644 --- a/build_readme.py +++ b/build_readme.py @@ -1,7 +1,17 @@ import markdown +from markdown.extensions.toc import slugify -html = markdown.markdownFromFile( - input="documentation_fr.md", +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', @@ -12,6 +22,15 @@ html = markdown.markdownFromFile( '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("
") +print(get_markdown("documentation_en.md", "en", "Table of contents")) +print("
") +print(get_markdown("documentation_fr.md", "fr", "Sommaire"))