From a959f5870f29f3c2f117bc4fe74988b08f5e95de Mon Sep 17 00:00:00 2001 From: plk Date: Sun, 17 Dec 2023 14:49:54 +0100 Subject: [PATCH] Looking at #466 --- bin/biber | 7 ++++--- lib/Biber/Output/bbl.pm | 4 ++-- lib/Biber/Output/bibtex.pm | 9 +++++++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/bin/biber b/bin/biber index 6df57ca31..1186f533a 100755 --- a/bin/biber +++ b/bin/biber @@ -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', @@ -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 (default 80). =item B<--xdatamarker=[marker]> diff --git a/lib/Biber/Output/bbl.pm b/lib/Biber/Output/bbl.pm index b95c483dd..8914ac5d1 100644 --- a/lib/Biber/Output/bbl.pm +++ b/lib/Biber/Output/bbl.pm @@ -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 @@ -132,7 +132,7 @@ sub _printfield { $str =~ s/(?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"; diff --git a/lib/Biber/Output/bibtex.pm b/lib/Biber/Output/bibtex.pm index e3bf2535f..27b9cf16d 100644 --- a/lib/Biber/Output/bibtex.pm +++ b/lib/Biber/Output/bibtex.pm @@ -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