1
0
Fork 0

Added -P option to msgfmt and moved addition of beginning and ending p tags from commit2html to msgfmt

This not only makes more sense, but allows raw (-i) mode to work properly
tpl
Mike Gerwitz 2013-05-27 16:50:34 -04:00
parent efa0adc41b
commit 80b466694b
4 changed files with 20 additions and 9 deletions

View File

@ -25,9 +25,5 @@ commit="${1?Missing commit}"
# provide default message formatter if necessary
msgfmt="${msgfmt:-./msgfmt}"
echo -n '<p>'
git show --pretty=format:%b "$commit" \
| "$msgfmt" "$commit"
echo '</p>'

21
msgfmt
View File

@ -27,6 +27,8 @@ id="$1"
lquo='\&ldquo;'
rquo='\&rdquo;'
mdash='\&mdash;'
opar='<p>'
epar='</p>'
# redefines replacements to yield plain text (instead of HTML entities)
nohtml()
@ -36,13 +38,24 @@ nohtml()
mdash=---
}
# no paragraph tags should be output
nopar()
{
opar=
epar=
}
while getopts n opt; do
while getopts nP opt; do
case "$opt" in
n) nohtml;;
P) nopar;;
esac
done
# calculate this after options have been parsed
refopar="${opar:+${opar%>} id="ref-\\1" class="ref">}"
# format the commit message, stopping at the diff (if any)
awk -vid="$id" -vurl_root="$url_root" -vcref_errlog="$cref_errlog" '
# replace commit refs with generated URL (allows linking to prior commits
@ -91,7 +104,7 @@ awk -vid="$id" -vurl_root="$url_root" -vcref_errlog="$cref_errlog" '
s#<a href="\([^"]\+\)\([.;,!]\)">\([^<]\+\).</a>#<a href="\1">\3</a>\2#g;
# reference definitions (footnotes)
s#\n\[\([0-9]\+\)\]#</p><p id="ref-\1" class="ref">&#g;
s#\n\[\([0-9]\+\)\]#'"$epar$refopar"'&#g;
# references in text (note that references that enclose text as a hyperlink
# must not start with a number, otherwise they will be considered to be a
@ -100,7 +113,9 @@ awk -vid="$id" -vurl_root="$url_root" -vcref_errlog="$cref_errlog" '
s|\[\([0-9]\+\)\]|<sup><a href="#ref-\1">&</a></sup>|g
# paragraphs
s#\n\n#</p>&<p>#g;
s#\n\n#'"$epar"'&'"$opar"'#g;
/^/i'"$opar"'
/$/a'"$epar"'
# basic formatting
s/---/'"$mdash"'/g;

View File

@ -109,7 +109,7 @@ do-index()
firstyear="$year"
pagefile="$( outfgen "$ts" "$id" "$html_ext" )"
fmtsubject="$( "$msgfmt" < <( echo "$subject"; echo ) )"
fmtsubject="$( "$msgfmt" -P < <( echo "$subject"; echo ) )"
[ "$prevdate" == "$dategroup" ] || {
[ -z "$prevdate" ] || $footout

2
raw
View File

@ -35,7 +35,7 @@ msgfmt="${2:-cat}"
# grab and format the subject (the template may or may not use it); note that
# 'q' includes the line that is matched (as opposed to Q), so the sed command
# will output the newline and leave the remaining input (the body) untouched
export subject="$( sed -u '/^$/q' | "$msgfmt" )"
export subject="$( sed -u '/^$/q' | "$msgfmt" -P )"
# the remainder of the input will be formatted and sent directly to the template
"$msgfmt" | "$tpl"