grip
grip copied to clipboard
table of contents?
Is there a way to generate a table of contents when using --export
?
Love this tool btw.
I am using the following in a bash script as a pre-processing step to achieve this atm.
rm -r temp.md
touch temp.md
echo -e "\n\nTOC\n" >> temp.md
IFS=$'\n';
for line in $(cat README.md | grep -E '^#+ ') ; do
heading=$(echo "${line}" | sed -re 's/[ \t]*$//' -e 's/^#+ (.*)$/\1/')
link=$(echo "${line}" | sed -re 's/[ \t]*$//' -e 's/^#+ (.*)/\1/' -e 's/ /-/g' -e 's/.*/\L&/g')
bullet=$(echo "${line}" | sed -re 's/^(#*)# .*/\1- /' -e 's/#/ /g')
echo "${bullet}[${heading}](#${link})" >> temp.md
done
echo -e "\n" >> temp.md
cat README.md >> temp.md
grip temp.md --export readme.html
I use doctoc.