aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2020-11-11 02:09:57 +0100
committerJohn Ankarström <john@ankarstrom.se>2020-11-11 02:09:57 +0100
commit6d4519c780aa7a8b0c329650ae1dcc653c5eb0de (patch)
tree043664d2cebc023891b6f077df1d4752e9e1030b
parentb0e00f631b1d5004afc483778fdd60bb549fe9a7 (diff)
downloadrf-6d4519c780aa7a8b0c329650ae1dcc653c5eb0de.tar.gz
fix format bug
-rw-r--r--rf.114
-rwxr-xr-xrf.pl14
2 files changed, 14 insertions, 14 deletions
diff --git a/rf.1 b/rf.1
index 89b5c05..24ac621 100644
--- a/rf.1
+++ b/rf.1
@@ -59,7 +59,7 @@ Default: (%a %y)
.It Sy \&Fl
Defines the format for the reference list, which is usually located at the end of the document.
.Pp
-Default: %a (%y). %t. %q. %n, %d. %c: %p. {Available: %w.}
+Default: %a (%y). {\\fI%t\\fR}. {\\*Q%q\\*U}. %n, %d. %c: %p. {Available: %w.}
.It Sy \&Fx
Defines the format for
.Dq alternate
@@ -172,16 +172,16 @@ For example:
By wrapping an interpolation in braces, you can specify a prefix and/or suffix that should be included only if the interpolation is successful.
For example:
.Bd -literal -offset indent
-\&.Ff (%a {,%y}). \\" The comma is removed if there is no year.
+\&.Ff (%a{, %y}). \\" Here, ', ' is removed if there is no year.
.Ed
.Pp
-You need not worry about excessive spaces, as
-.Nm
-removes these automatically.
-.Pp
-All fields are inserted literally, except
+Note that all fields are inserted literally, except
.Em %a ,
from which the forenames of the authors are removed.
+.Pp
+Finally, you usually don't need to worry about excessive spaces and stray punctuation marks, as
+.Nm
+removes many of these these automatically.
.
.Sh AUTHORS
.Nm
diff --git a/rf.pl b/rf.pl
index 7696921..bf54bb5 100755
--- a/rf.pl
+++ b/rf.pl
@@ -7,7 +7,7 @@ use warnings;
my $format_full = '(%a %y)';
my $format_extra = '(%y)';
-my $format_list = '%a (%y). %t. %q. %n, %d. %c: %p. {Available: %w.}';
+my $format_list = '%a (%y). {\fI%t\fR}. {\*Q%q\*U}. %n, %d. %c: %p. {Available: %w.}';
# Internal variables
@@ -112,17 +112,17 @@ sub fmt {
no warnings;
my $val = $ref{$fld};
$val = fmta($val) if $fld eq 'a' and not $full;
- $fmt =~ s/\{(.*?)%$fld(.*?)}/$1$val$3/g;
- $fmt =~ s/%$fld/$val/g;
+ $fmt =~ s/\{([^{}%]*)%\Q$fld\E([^{}]*)}/$1$val$2/g;
+ $fmt =~ s/%\Q$fld\E/$val/g;
} else {
no warnings;
- $fmt =~ s/\{(.*?)%$fld(.*?)}//g;
- $fmt =~ s/[.(]?%$fld[.,:;)]?//g;
+ $fmt =~ s/[.(]?\{([^{}%]*)%\Q$fld\E([^{}]*)}[.,:;)]?//g;
+ $fmt =~ s/[.(]?%\Q$fld\E[.,:;)]?//g;
}
}
$fmt =~ s/ +/ /g;
- $fmt =~ s/([(]) */$1/;
- $fmt =~ s/ *([.,)])/$1/;
+ #$fmt =~ s/([(]) +/$1/;
+ #$fmt =~ s/ +([.,)])/$1/;
$fmt =~ s/^ *//;
$fmt =~ s/ *$//;
return $fmt;