1
0
Fork 0

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.
master
Mike Gerwitz 2012-10-28 00:03:31 -04:00
parent ba85af8b52
commit 16993151a8
No known key found for this signature in database
GPG Key ID: F22BB8158EE30EAB
1 changed files with 5 additions and 3 deletions

8
msgfmt
View File

@ -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/\&/\&amp;/g;
s/</\&lt;/g;
@ -54,10 +57,9 @@ awk '/^diff --git/ { exit } { print }' \
s#\n\n \+\(\([^\n]\+\n\(\n \+\)\?\)\+\)#<blockquote>\1</blockquote>#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 )]\+#<a href="&">&</a>#g;
s#<a href="\([^"]\+\)\([.;,!]\)">\([^<]\+\).</a>#<a href="\1">\3</a>\2#g;
# reference definitions (footnotes)
s#\n\[\([0-9]\+\)\]#</p><p id="ref-\1">&#g;