ESP3D/docs/pagespliter.py
Luc cda276e2e6
Settings validation refactoring (#964)
* Rewrite the setting API to use same API as ESP3D-TFT or at least close enough to be improved - WIP

* Add isValidXXX setting API

* Factorize dispatch_setting for ESP400

* ESP400 refactoring
2023-11-09 10:29:13 +08:00

41 lines
895 B
Python

#!/usr/bin/env python3
import os
input_file = "espXXX.md"
output_file_head = "esp"
output_ext = ".md"
f = open(input_file, "r")
lines = f.readlines()
#parse each lines
head = ""
have_command = False
fo=0
count = 0
for line in lines:
if not have_command:
count=0
head+=line
if line.startswith("title ="):
have_command = True
num = line.split("ESP")[1].split("]")[0]
fo = open(output_file_head+num+output_ext, "w")
fo.write(head)
have_command = True
else:
if line.startswith("+++"):
count+=1
if count==2:
fo.close()
have_command = False
head = line
print("close file "+output_file_head+num+output_ext)
else:
fo.write(line)
else:
fo.write(line)
f.close()