ekalinin / github-markdown-toc

Easy TOC creation for GitHub README.md
MIT License
3.23k stars 2.75k forks source link

[Feature] Auto insert support recursive folders, and auto skip files without `<!--ts-->` #110

Open vikyd opened 3 years ago

vikyd commented 3 years ago

Wants 2 features:

vikyd commented 3 years ago

Here is my temporary solution, it works in my repo :

getTocMdFiles(){
  find . -iname '*.md' \
  | xargs grep -nwlzP -e '<!--ts-->' | xargs grep -nwlzP -e '<!--te-->'
}

echo "Generate TOC begin: ..."
getTocMdFiles | xargs -L 1 -P 50 gh-md-toc --insert --no-backup 
echo "Generate TOC end."
echo "-----------------"

echo "Remove time row in TOC begin: ..."
# remove time content to aviod too many changes
getTocMdFiles | xargs sed -i '/<!-- Added by:/d' 
echo "Remove time row in TOC end."
yiranzai commented 3 years ago

I have the same idea And https://github.com/ekalinin/github-markdown-toc/pull/115 https://github.com/ekalinin/github-markdown-toc/pull/117