Verified Commit 3ee4990e authored by Laurent Heirendt's avatar Laurent Heirendt
Browse files

inplace editing of index

parent da014728
......@@ -59,7 +59,7 @@ index = ""
for d in dirs:
# set the header of the section
index += "### " + d.capitalize() + "\n"
index += "\n### " + d.capitalize() + "\n"
localIndexArr = []
# walk through the folders with all the cards
......@@ -115,7 +115,7 @@ for d in dirs:
title = title[2:]
#index += " * [" + title + "](./" + root + "/" + "\n"
localIndexArr.append(" * [" + title + "](./" + root + "/" + "\n")
localIndexArr.append(" * [" + title + "](./" + root + "/" + ")\n")
# output
print(" + New header added.")
......@@ -126,4 +126,15 @@ for d in dirs:
index += ''.join(localIndexArr)
# output the index
print(index)
\ No newline at end of file
#print(index)
# Read in the file
indexFile = "index.md"
with open(indexFile, 'r') as file :
filedata = file.read()
# Replace the target string
filedata = filedata.replace('[[ index ]]', index)
# Write the file out again
with open(indexFile, 'w') as file:
file.write(filedata)
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment