Fix input fetching script
Retain blank lines in code examples. The script removed all blank lines from code examples. This is not always desired as there might be important blank lines inside the code block. The change targets specifically the starting and ending blank line of the examples and removes them.
This commit is contained in:
parent
4f13984375
commit
861dfd0bc5
@ -26,8 +26,11 @@ echo "Extracting example code blocks..."
|
||||
# extract example code blocks
|
||||
cat README.md |
|
||||
sed -n '/\[code\]/,/\[\/code\]/p' | # extract code blocks
|
||||
sed '/^\s*$/d' | # remove empty lines
|
||||
sed '/^\[\/code\]/d' | # remove closing bracket
|
||||
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)
|
||||
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."
|
||||
|
Loading…
Reference in New Issue
Block a user