Skip to content

Commit

Permalink
Enable auto-generation of linklist.md
Browse files Browse the repository at this point in the history
Signed-off-by: David A. Wheeler <[email protected]>
  • Loading branch information
david-a-wheeler committed May 20, 2024
1 parent 172a86c commit 416db58
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
12 changes: 12 additions & 0 deletions make_linklist
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

url='https://github.com/ossf/secure-sw-dev-fundamentals/blob/main/secure_software_development_fundamentals.md'
while read line; do
case "$line" in
\#*)
name=$(printf '%s\n' "$line" | sed -e 's/^#* //')
link=$(printf '%s\n' "$name" | tr -dc 'A-Za-z0-9 -' | tr 'A-Z ' 'a-z-')
printf '%s\n' "[${name}](${url}#${link})"
;;
esac
done
5 changes: 4 additions & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ toc.md: secure_software_development_fundamentals.md tocignore
grep -E '^#{1,3} ' secure_software_development_fundamentals.md | \
grep -E -v -f tocignore | while read line; do echo "$$line"; echo; done > toc.md

linklist.md: toc.md make_linklist
./make_linklist < toc.md > linklist.md

# This requires wkhtmltopdf because it goes via HTML
# https://plaintextproject.online/articles/2022/04/06/pdf.html
# https://stackoverflow.com/questions/38455078/specifying-papersize-for-md-to-pdf-conversion
Expand All @@ -18,4 +21,4 @@ toc.md: secure_software_development_fundamentals.md tocignore
book.pdf: secure_software_development_fundamentals.md
pandoc -f gfm --pdf-engine=wkhtmltopdf \
--css=print.css -V geometry:a4paper -o book.pdf \
secure_software_development_fundamentals.md
secure_software_development_fundamentals.md

0 comments on commit 416db58

Please sign in to comment.