toc added
This commit is contained in:
parent
5aa5a184fa
commit
87fb1b1ef8
@ -20,6 +20,7 @@ lTitel = []
|
||||
lText = []
|
||||
lItemName = []
|
||||
lPlanTable = []
|
||||
lTocLinks = []
|
||||
|
||||
def lua_table(name, lData):
|
||||
lOut = []
|
||||
@ -80,6 +81,7 @@ class MyRenderer(mistune.Renderer):
|
||||
self.add_last_paragraph()
|
||||
self.is_first_header = False
|
||||
lTitel.append("%u,%s" % (level, formspec_escape(text)))
|
||||
lTocLinks.append({"level": level, "header": formspec_escape(text), "link": self.src_name})
|
||||
return ""
|
||||
|
||||
def hrule(self):
|
||||
@ -143,6 +145,7 @@ def parse_md_file(src_name, mod, manual):
|
||||
print("Read Lua file '%s'" % src_name)
|
||||
renderer = MyRenderer()
|
||||
md = mistune.Markdown(renderer=renderer)
|
||||
md.renderer.src_name = src_name
|
||||
md.render(file(src_name).read())
|
||||
md.renderer.add_last_paragraph()
|
||||
|
||||
@ -155,6 +158,15 @@ def gen_lua_file(dest_name):
|
||||
lOut.append(lua_table("%s.%s.aPlanTable" % (mod, manual), lPlanTable))
|
||||
file(dest_name, "w").write("".join(lOut))
|
||||
|
||||
def gen_toc_md_file(dest_name, titel):
|
||||
print("Write MD file '%s'" % dest_name)
|
||||
lOut = ["# "+ titel]
|
||||
lOut.append("")
|
||||
for item in lTocLinks:
|
||||
list_item = " " * (item["level"] - 1) + "-"
|
||||
link = "%s#%s" % (item["link"], item["header"].lower().replace(" ", "-"))
|
||||
lOut.append("%s [%s](%s)" % (list_item, item["header"], link))
|
||||
file(dest_name, "w").write("\n".join(lOut))
|
||||
|
||||
mod = "techage"
|
||||
manual = "manual_DE"
|
||||
@ -162,3 +174,4 @@ parse_md_file("./manual_DE.md", mod, manual)
|
||||
parse_md_file("./manual_ta1_DE.md", mod, manual)
|
||||
parse_md_file("./manual_ta2_DE.md", mod, manual)
|
||||
gen_lua_file("../doc/manual_DE.lua")
|
||||
gen_toc_md_file("./toc_DE.md", "Inhaltsverzeichnis")
|
||||
|
34
manuals/toc_DE.md
Normal file
34
manuals/toc_DE.md
Normal file
@ -0,0 +1,34 @@
|
||||
# Inhaltsverzeichnis
|
||||
|
||||
- [Tech Age Mod](./manual_DE.md#tech-age-mod)
|
||||
- [Hinweise](./manual_DE.md#hinweise)
|
||||
- [TA1: Eisenzeitalter](./manual_ta1_DE.md#ta1:-eisenzeitalter)
|
||||
- [Köhler](./manual_ta1_DE.md#köhler)
|
||||
- [Kohlebrenner](./manual_ta1_DE.md#kohlebrenner)
|
||||
- [Erze und Werkzeuge](./manual_ta1_DE.md#erze-und-werkzeuge)
|
||||
- [Hammer](./manual_ta1_DE.md#hammer)
|
||||
- [Kiessieb](./manual_ta1_DE.md#kiessieb)
|
||||
- [Trichter](./manual_ta1_DE.md#trichter)
|
||||
- [Kies sieben mit dem Trichter](./manual_ta1_DE.md#kies-sieben-mit-dem-trichter)
|
||||
- [Meridium](./manual_ta1_DE.md#meridium)
|
||||
- [TA2: Dampfzeitalter](./manual_ta2_DE.md#ta2:-dampfzeitalter)
|
||||
- [Dampfmaschine](./manual_ta2_DE.md#dampfmaschine)
|
||||
- [TA2 Feuerbox](./manual_ta2_DE.md#ta2-feuerbox)
|
||||
- [TA2 Boiler](./manual_ta2_DE.md#ta2-boiler)
|
||||
- [TA2 Zylinder](./manual_ta2_DE.md#ta2-zylinder)
|
||||
- [TA2 Schwungrad](./manual_ta2_DE.md#ta2-schwungrad)
|
||||
- [TA2 Dampfleitungen](./manual_ta2_DE.md#ta2-dampfleitungen)
|
||||
- [Items schieben und sortieren](./manual_ta2_DE.md#items-schieben-und-sortieren)
|
||||
- [Röhren](./manual_ta2_DE.md#röhren)
|
||||
- [TA2 Schieber](./manual_ta2_DE.md#ta2-schieber)
|
||||
- [TA2 Verteiler](./manual_ta2_DE.md#ta2-verteiler)
|
||||
- [Kieswaschanlage](./manual_ta2_DE.md#kieswaschanlage)
|
||||
- [TA2 Kiesspüler](./manual_ta2_DE.md#ta2-kiesspüler)
|
||||
- [Stein mahlen und sieben](./manual_ta2_DE.md#stein-mahlen-und-sieben)
|
||||
- [TA2 Mühle](./manual_ta2_DE.md#ta2-mühle)
|
||||
- [TA2 Kiessieb](./manual_ta2_DE.md#ta2-kiessieb)
|
||||
- [Items produzieren](./manual_ta2_DE.md#items-produzieren)
|
||||
- [TA2 Autocrafter](./manual_ta2_DE.md#ta2-autocrafter)
|
||||
- [TA2 Elektronikfabrik](./manual_ta2_DE.md#ta2-elektronikfabrik)
|
||||
- [Sonstige Blöcke](./manual_ta2_DE.md#sonstige-blöcke)
|
||||
- [TA2 Flüssigkeitensammler](./manual_ta2_DE.md#ta2-flüssigkeitensammler)
|
Loading…
Reference in New Issue
Block a user