URI:
       tgetrefer: print author names with surname last - scholarref - tools for DOI and BiBTeX reference extraction, fetching, and parsing
  HTML git clone git://src.adamsgaard.dk/scholarref
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit c43d234e7a6695d554d48a80e6696f0fd5f94545
   DIR parent 3d882361dc345c819ecb50919dfb34fa42e37c7f
  HTML Author: Anders Damsgaard <anders@adamsgaard.dk>
       Date:   Wed, 24 Nov 2021 20:02:30 +0100
       
       getrefer: print author names with surname last
       
       Diffstat:
         M getrefer                            |      18 ++++++++++++------
       
       1 file changed, 12 insertions(+), 6 deletions(-)
       ---
   DIR diff --git a/getrefer b/getrefer
       t@@ -6,24 +6,30 @@ do
                curl -sLH "Accept: application/x-research-info-systems" "https://doi.org/${doi}"
        done | \
        awk '
       -function rmlbl(s) {
       +function rmlbl() {
                sub(/[A-Za-z][A-Za-z0-9]  - /, "");
        }
        
        BEGIN { delete authors[0] }
        
        /DO  - / { doi = $3 }
       -/TI  - / { rmlbl($0); title = $0 }
       -/T2  - / { rmlbl($0); journal = $0 }
       -/AU  - / { rmlbl($0); authors[length(authors)] = $0 }
       +/TI  - / { rmlbl(); title = $0 }
       +/T2  - / { rmlbl(); journal = $0 }
        /PY  - / { year = $3 }
        /SP  - / { page = $3 }
        /IS  - / { issue = $3 }
        /VL  - / { volume = $3 }
       +/AU  - / {
       +        rmlbl()
       +        if (length(authors) == 0) {
       +                firstauthor = $0
       +                sub(/,.*/, "", firstauthor)
       +        }
       +        split($0, a, /, /)
       +        authors[length(authors)] = sprintf("%s %s", a[2], a[1])
       +}
        
        END {
       -        firstauthor = authors[0]
       -        sub(/,.*/, "", firstauthor)
                printf "%%L %s%d\n", firstauthor, year
                for (i in authors)
                        printf "%%A %s\n", authors[i]