From 16993151a8b5b0e897038f1616e35c156bd2fc07 Mon Sep 17 00:00:00 2001
From: Mike Gerwitz
Date: Sun, 28 Oct 2012 00:03:31 -0400
Subject: [PATCH] Hyperlink-related enhancements to msgfmt
- Removing <> delimiters from links
- Stripping punctuation from the end of links
Yes, Perl would be easier, but I'd prefer to avoid the dependency if at all
possible. If this gets too much more complicated, Perl may be a necessity to
prevent a maintinance nightmare.
---
msgfmt | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/msgfmt b/msgfmt
index 3140f57..9937e01 100755
--- a/msgfmt
+++ b/msgfmt
@@ -44,6 +44,9 @@ done
# format the commit message, stopping at the diff (if any)
awk '/^diff --git/ { exit } { print }' \
| sed ':a;N;$!ba;
+ # handle <>-delimited links (strip delimiters)
+ s#<\([fh]ttps\?://[^ ]\+\)>#\1#g;
+
# escaping
s/\&/\&/g;
s/\</g;
@@ -54,10 +57,9 @@ awk '/^diff --git/ { exit } { print }' \
s#\n\n \+\(\([^\n]\+\n\(\n \+\)\?\)\+\)#\1
#g
# unfortunately, non-greedy matches make it difficult to exclude punctuation
- # at the end of a link, so we will not be handling it here (since links
- # should always be in the footer as references (ideally), this should not
- # happen
+ # at the end of a link, so we will handle it in a separate expression
s#[fh]ttps\?://[^]\n )]\+#&#g;
+ s#\([^<]\+\).#\3\2#g;
# reference definitions (footnotes)
s#\n\[\([0-9]\+\)\]#
g;