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
parent
ba85af8b52
commit
16993151a8
8
msgfmt
8
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 \+\)\?\)\+\)#<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;
|
||||
|
|
Loading…
Reference in New Issue