diff --git a/lib/aoc.sh b/lib/aoc.sh index 3c84954..3ae3e19 100755 --- a/lib/aoc.sh +++ b/lib/aoc.sh @@ -26,12 +26,12 @@ echo "Extracting example code blocks..." # extract example code blocks cat README.md | sed -n '/\[code\]/,/\[\/code\]/p' | # extract code blocks - sed '/\[code\]/{n;d}' | # remove (blank) lines after opening bracket + sed 's/^ //' | # remove indentation + sed '/\[code\]/{n;/^$/d}' | # remove blank lines after opening bracket tac | # reverse line order - sed '/\[\/code\]/{n;d}' | # remove (blank) lines after closing brackets (preceding blank lines in normal order) + sed '/\[\/code\]/{n;/^$/d}' | # remove blank lines after closing brackets (preceding blank lines in normal order) tac | # reverse line order again sed '/^\[\/code\]/d' | # remove closing brackets - sed 's/^ //' | # remove indentation csplit - --suppress-matched --elide-empty-files --prefix='input/example' --suffix='%d' '/\[code\]/' '{*}' echo "done."