book: add makefile step to remove arrow keys from book js

This commit is contained in:
x
2023-09-12 08:03:35 +02:00
parent b314daafc3
commit 70e5eae6ac
2 changed files with 37 additions and 0 deletions

View File

@@ -14,6 +14,7 @@ all: $(JSONRPC)
./generate_seminar_ics.py --ics
$(MAKE) -C ../ rustdoc
cp -r ../target/doc/* book/development/
./remove_chapter_nav_js.py
$(DARKFID_JSONRPC):
@echo "# darkfid JSON-RPC API" > $@

View File

@@ -0,0 +1,36 @@
#!/usr/bin/env python3
# cp book/book.js /tmp/
# python remove_chapter_nav_js.py
# diff book/book.js /tmp/book.js
with open("book/book.js") as f:
lines = f.read()
lines = lines.split("\n")
pre = []
while True:
line = lines[0]
if "chapterNavigation()" in line:
break
pre.append(lines.pop(0))
# chapterNavigation() {
lines.pop(0)
i = 1
while True:
line = lines.pop(0)
i += line.count("{") - line.count("}")
assert i >= 0
if i == 0:
break
src = "\n".join(pre + lines)
#print(src)
with open("book/book.js", "w") as f:
f.write(src)