]>
Commit | Line | Data |
---|---|---|
2ca79e96 | 1 | import markdown |
faed2fa8 | 2 | from markdown.extensions.toc import slugify |
2ca79e96 | 3 | |
faed2fa8 IB |
4 | def lang_slugify(lang): |
5 | def l_slugify(value, separator): | |
6 | return slugify(lang + "__" + value, separator) | |
7 | return l_slugify | |
8 | ||
9 | def 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 | ||
31 | print("<p><a href='#lang-en'>Documenation in english</a></p>") | |
32 | print("<p><a href='#lang-fr'>Documenation en Français</a></p>") | |
360c4029 | 33 | print("<p><a href='#lang-bottom'>Bottom of documentation</a></p>") |
faed2fa8 IB |
34 | print("<hr id='lang-en'/>") |
35 | print(get_markdown("documentation_en.md", "en", "Table of contents")) | |
36 | print("<hr id='lang-fr'/>") | |
37 | print(get_markdown("documentation_fr.md", "fr", "Sommaire")) | |
360c4029 | 38 | print("<hr id='lang-bottom' style='visibility: hidden' />") |