Skip to content

Commit

Permalink
Looking at #466
Browse files Browse the repository at this point in the history
  • Loading branch information
plk committed Dec 17, 2023
1 parent 1d7e68c commit a959f58
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
7 changes: 4 additions & 3 deletions bin/biber
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ GetOptions(
'validate_datamodel|validate-datamodel|V',
'version|v',
'winunicode|W',
'wraplines|w',
'wraplines|w:80',
'xdatamarker=s',
'xdatasep=s',
'xnamesep=s',
Expand Down Expand Up @@ -1009,9 +1009,10 @@ system APIs. If that option is enabled, use this option to turn off biber's
UTF-16 filename support on Windows. This will result in much improved
handling of Unicode filenames.
=item B<--wraplines|-w>
=item B<--wraplines|-w=[column]>
Wrap lines in the F<.bbl> file.
Wrap lines in the F<.bbl> file (or output F<.bib> file in tool mode) at column
F<column> (default 80).
=item B<--xdatamarker=[marker]>
Expand Down
4 changes: 2 additions & 2 deletions lib/Biber/Output/bbl.pm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use Scalar::Util qw(looks_like_number);
use Text::Wrap;
use Unicode::Normalize;
use URI;
$Text::Wrap::columns = 80;

my $logger = Log::Log4perl::get_logger('main');

=encoding utf-8
Expand Down Expand Up @@ -132,7 +132,7 @@ sub _printfield {
$str =~ s/(?<!\\)(\#|\&|\%)/\\$1/gxms;
}

if (Biber::Config->getoption('wraplines')) {
if ($Text::Wrap::columns = Biber::Config->getoption('wraplines')) {
## 16 is the length of ' \field{}{}' or ' \strng{}{}'
if ( 16 + Unicode::GCString->new($outfield)->length + Unicode::GCString->new($str)->length > 2*$Text::Wrap::columns ) {
return " \\${field_type}{$outfield}{%\n" . wrap(' ', ' ', $str) . "%\n }\n";
Expand Down
9 changes: 7 additions & 2 deletions lib/Biber/Output/bibtex.pm
Original file line number Diff line number Diff line change
Expand Up @@ -574,9 +574,14 @@ sub bibfield {
else {
$acc .= "\{$value\},\n";
}
return $acc;
}

if ($Text::Wrap::columns = Biber::Config->getoption('wraplines')) {
return wrap('', $ichar x $inum, $acc);
}
else {
return $acc;
}
}

=head2 construct_annotation
Expand Down

0 comments on commit a959f58

Please sign in to comment.