This repository has been archived on 2025-12-28. You can view files and clone it, but cannot push or open issues or pull requests.
inks-scripts/scripts/zk-gen-index
2023-01-27 22:10:11 +10:30

15 lines
318 B
Bash
Executable File

#!/usr/bin/env bash
toc=$(zk-gen-dir-md-toc)
echo -e "START_TOC$toc\nEND_TOC" > temp.md
if [ -f index.md ]; then
perl -i -p0e 's/START_TOC.*END_TOC/`cat temp.md`/se' index.md
# sed -i "s/START_TOC.*END_TOC/\${toc}/g" index.md
else
echo -e "# Index\n\nSTART_TOC\n$toc\nEND_TOC" > index.md
fi
rm temp.md