1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
# Fix up readmes:
# * Replace ## with # in code blocks.
# * Remove [] without a following () from output.
BEGIN {
true = 1
false = 0
in_block = false
}
{
if (!in_block && $0 ~ /^```/) {
in_block = true
} else if (in_block && $0 ~ /^```$/) {
in_block = false
}
if (in_block) {
sub(/## /, "# ")
print $0
} else {
# Strip [] without a () that immediately follows them from
# the output.
subbed = gensub(/\[([^\[]+)]([^\(]|$)/, "\\1\\2", "g")
print subbed
}
}
|