1
0
Fork 0
easejs/tools/news-fmt

68 lines
1.9 KiB
Plaintext
Raw Permalink Normal View History

#!/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 <http://www.gnu.org/licenses/>.
##
# formats for HTML output
function escprint( str )
{
# escapes
gsub( /&/, "\\&amp;", str )
gsub( /</, "\\&lt;", str )
gsub( />/, "\\&gt;", str )
# hyperlinks
print gensub( /(https?:\/\/.+)(>|\. )/, \
"<a href=\"\\1\">\\1</a>\\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 "<h3 id=\"%s\" class=\"git-commit\">", commit
do {
escprint( $0 " " )
} while ( getline && !/^ $/ );
# close subject line
printf "</h3>"
# author
printf "<div class=\"git-commit-author\">%s</div>", author
# date
printf "<div class=\"git-commit-date\">%s</div>", date
# the rest of the commit (that is, until we find a line with
# non-whitespace in column one) is the body
printf "<pre>"
while ( getline && /^\W/ ) {
escprint( $0 )
}
printf "</pre>"
}