Skip to content

Commit

Permalink
updated markdown_generate_index.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
HariSekhon committed Aug 17, 2024
1 parent 9a459fe commit 6a7aef0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion git/markdown_generate_index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,18 @@ if ! [ -f "$markdown_file" ]; then
die "File not found: $markdown_file"
fi

# since we now strip ```code``` blocks we must ensure that they match otherwise this code cannot
# reliably run as it'll result in stripping out valid headings

if [ "$(( $(grep -c '^```' "$markdown_filek) % 2))" != 0 ]; then
die "Error - uneven number of code blocks found in file: $markdown_file"
fi

# sed strip out ```code``` blocks to avoid # comments inside code blocks from going into the index
# tail -n +2 takes off the first line which is the header we definitely don't want in the index
# false positive
# shellcheck disable=SC2016
sed '/```/,/```/d' "$markdown_file" |
sed '/^```/,/^```/d' "$markdown_file" |
grep -E '^#+[[:space:]]' |
tail -n +2 |
# don't include main headings
Expand Down

0 comments on commit 6a7aef0

Please sign in to comment.