#!/usr/bin/gawk -f # # Formats NEWS for display on the website # # Copyright (C) 2014 Free Software Foundation, Inc. # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation, either version 3 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . ## # formats for HTML output function escprint( str ) { # escapes gsub( /&/, "\\&", str ) gsub( //, "\\>", str ) # hyperlinks print gensub( /(https?:\/\/.+)(>|\. )/, \ "\\1\\2", str \ ) } match( $0, /^commit *(.{7})/, m ) { commit = m[1]; next } match( $0, /^Author: *([^<]+)/, m ) { author = m[1]; next } match( $0, /^Date: *[^ ]+ ([^ ]+ [^ ]+ [^ ]+)/, m ) { date = m[1]; next } # commit messages are indented by four spaces, with the subject line # occupying the first paragraph (that is---until an empty line) /^ / { # begin the subject line output printf "

", commit do { escprint( $0 " " ) } while ( getline && !/^ $/ ); # close subject line printf "

" # author printf "
%s
", author # date printf "
%s
", date # the rest of the commit (that is, until we find a line with # non-whitespace in column one) is the body printf "
"
  while ( getline && /^\W/ ) {
    escprint( $0 )
  }
  printf "
" }