]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/blob - build_readme.py
Add immae_config.yaml
[perso/Immae/Projets/Cryptomonnaies/BIP39.git] / build_readme.py
1 import markdown
2 from markdown.extensions.toc import slugify
3
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,
15 extensions=[
16 'markdown.extensions.codehilite',
17 'markdown.extensions.toc',
18 'markdown.extensions.tables'
19 ],
20 extension_configs={
21 'markdown.extensions.codehilite': {
22 'noclasses': True,
23 },
24 'markdown.extensions.toc': {
25 'title': table_of_content,
26 'slugify': lang_slugify(lang)
27 }
28 })
29
30
31 print("<p><a href='#lang-bottom'>Bottom of documentation</a></p>")
32 print(get_markdown("readme.md", "en", "Table of contents"))
33 print("<hr id='lang-bottom' style='visibility: hidden' />")