]> git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/blame - build_readme.py
Add config
[perso/Immae/Projets/Python/MusicSampler.git] / build_readme.py
CommitLineData
2ca79e96 1import markdown
faed2fa8 2from markdown.extensions.toc import slugify
2ca79e96 3
faed2fa8
IB
4def lang_slugify(lang):
5 def l_slugify(value, separator):
6 return slugify(lang + "__" + value, separator)
7 return l_slugify
8
9def get_markdown(md_file, lang, table_of_content):
10 with open(md_file, "r") as f:
11 text = f.read()
12
13 return markdown.markdown(
14 text=text,
db905e07
IB
15 extensions=[
16 'markdown.extensions.codehilite',
cfde9820
IB
17 'markdown.extensions.toc',
18 'markdown.extensions.tables'
db905e07 19 ],
2ca79e96
IB
20 extension_configs={
21 'markdown.extensions.codehilite': {
22 'noclasses': True,
940ccd88
IB
23 },
24 'markdown.extensions.toc': {
faed2fa8
IB
25 'title': table_of_content,
26 'slugify': lang_slugify(lang)
2ca79e96
IB
27 }
28 })
faed2fa8
IB
29
30
31print("<p><a href='#lang-en'>Documenation in english</a></p>")
32print("<p><a href='#lang-fr'>Documenation en Français</a></p>")
360c4029 33print("<p><a href='#lang-bottom'>Bottom of documentation</a></p>")
faed2fa8
IB
34print("<hr id='lang-en'/>")
35print(get_markdown("documentation_en.md", "en", "Table of contents"))
36print("<hr id='lang-fr'/>")
37print(get_markdown("documentation_fr.md", "fr", "Sommaire"))
360c4029 38print("<hr id='lang-bottom' style='visibility: hidden' />")