diff options
1 files changed, 14 insertions, 11 deletions
| -rwxr-xr-x | csg | 25 |
@@ -217,16 +217,18 @@ transform-file() { local scripts="$2" # Gets special information from the file - local title="$($CSG_AWK -v titlef="$TITLEF" ' - /^# / { + local title descr words + { read -r title; read -r descr; read -r words; } << EOF +$($CSG_AWK -v titlef="$TITLEF" ' + title == "" && /^# / { # Remove first field $1 = ""; sub(FS, "") # Output title - sub(/.*/, titlef); print - exit - }' "$file")" - local descr="$($CSG_AWK ' - /^[[:alpha:]]/ { + sub(/.*/, titlef) + title = $0 + next + } + stopdesc == 0 && /^[[:alpha:]]/ { startedGathering = 1 # Take only anchor text gsub(/\]\([^)]*\)/, "") @@ -237,13 +239,14 @@ transform-file() { # Trim line to 200 characters if (length(desc) > 200) { desc = substr(desc, 1, 197) "..." - exit + stopdesc = 1 } } startedGathering && /^$/ { exit } - END { print desc }' "$file")" - local words="$($CSG_AWK '{total += NF} END{print total}' "$file")" - local timestamps=($($CSG_AWK -v file="$outf" ' + { words += NF } + END { print title ORS desc ORS words }' "$file") +EOF + BEGIN { FS = "\t" } $1 == file { print $2 |
