#!/usr/bin/gawk -f # # Formats NEWS for display on the website # # Copyright (C) 2014 Mike Gerwitz # # 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 \ ) } /^commit / { next } # store author match( $0, /^Author: *([^<]+)/, author ) { next } # store date match( $0, /^Date: *(.+)$/, date ) { 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 "

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

" # 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 "
" }