-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
47 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,5 @@ black: | |
python -m black .## Run ci part | ||
.PHONY: ci | ||
ci: lint test | ||
toc: | ||
cat README.md | bash toc.sh 2 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
# It will read the input and: | ||
# | ||
# 1. Extract only the headers via grep (using $1 and $2 as first and last heading level) | ||
# 2. Extract the header text via sed and created ':' separated records of the form '###:Full Text:Full Text' | ||
# 3. Compose each TOC line via awk by replacing '#' with ' ' and stripping spaces and caps of reference | ||
|
||
grep -E "^#{${1:-1},${2:-2}} " | \ | ||
sed -E 's/(#+) (.+)/\1:\2:\2/g' | \ | ||
awk -F ":" '{ gsub(/#/," ",$1); gsub(/[ ]/,"-",$3); print $1 "- [" $2 "](#" tolower($3) ")" }' |