#!/usr/bin/gawk -f # Last edited on 2021-03-04 02:57:03 by jstolfi # Reads a page of URLs and section headers. Convert the URLs # to HTML links. BEGIN { nsec = 0 # Number of secttions started unproc = 1 # Curent section had an unprocessed header. } /^ *$/{ next } /[<]h3[>]/ { # Prevously processed section, increment the count: nsec++ unproc = 0 print next } /^[<]/ { # Prevously processed, just keep it: print next } /https?:|file:/ { # Unprocessed URL: printf "
  • %s

  • \n", nsec, $0, $0 next } // { # Unprocessed section header: if ((nsec > 0) && (unproc != 0)) { printf "\n" , nsec } nsec++ printf "\n", nsec printf "

    %s

    \n", nsec, $0 printf "\n" , nsec printf "