Difference between revisions of "Literate programming/Bird conversion via awk"
Jump to navigation
Jump to search
(fix missing slashes) |
(Support files with lines which end right after the initial ">".) |
||
Line 7: | Line 7: | ||
/^>/ { |
/^>/ { |
||
print "\\begin{code}" |
print "\\begin{code}" |
||
− | sub(/^> /,"") |
+ | sub(/^>( |$)/,"") |
print |
print |
||
rc = getline |
rc = getline |
||
while(($0 ~ /^>/) && (rc > 0)) { |
while(($0 ~ /^>/) && (rc > 0)) { |
||
− | sub(/^> /,"") |
+ | sub(/^>( |$)/,"") |
print |
print |
||
rc = getline |
rc = getline |
Latest revision as of 12:39, 11 July 2018
Thanks to Peter Tillier from the comp.lang.awk newsgroup.
# bird2code.awk /^[^>]/ || /^$/ {print; next} /^>/ { print "\\begin{code}" sub(/^>( |$)/,"") print rc = getline while(($0 ~ /^>/) && (rc > 0)) { sub(/^>( |$)/,"") print rc = getline } print "\\end{code}\n" }