import markdown from markdown.extensions.toc import slugify 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': 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("")