1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-02-17 21:02:25 +02:00

doc: help2man: account for undisplayed markup in indenting calculations

* man/help2man: This is significant with the indented line
following the dd bs=BYTES "option" at least.
This commit is contained in:
Pádraig Brady
2026-01-16 18:09:16 +00:00
parent ed91d9a218
commit 5939e67704

View File

@@ -50,6 +50,7 @@ sub get_option_value;
sub convert_option;
sub fix_italic_spacing;
sub set_indent;
sub visual_length;
my $version_info = enc_user sprintf _(<<'EOT'), $this_program, $this_version;
GNU %s %s
@@ -537,12 +538,12 @@ while (length)
if (s/^( {1,10}([+-]\S.*?))(?:( +(?!-))|\n( {7,}))(\S.*)\n//)
{
$matched .= $& if %append_match;
$indent = set_indent length ($4 || "$1$3");
$indent = set_indent visual_length ($4 || "$1$3");
$content = ".TP\n\x84$2\n\x84$5\n";
unless ($4)
{
# Indent may be different on second line.
$indent = set_indent length $& if /^ {20,}/;
$indent = set_indent visual_length $& if /^ {20,}/;
}
}
@@ -558,7 +559,7 @@ while (length)
elsif (s/^( +(\S.*?) +)(\S.*)\n//)
{
$matched .= $& if %append_match;
$indent = set_indent length $1;
$indent = set_indent visual_length $1;
$content = ".TP\n\x84$2\n\x84$3\n";
}
@@ -566,7 +567,7 @@ while (length)
elsif (s/^( +)(\S.*)\n//)
{
$matched .= $& if %append_match;
$indent = set_indent length $1;
$indent = set_indent visual_length $1;
$content = ".IP\n\x84$2\n";
}
@@ -869,3 +870,13 @@ sub set_indent
$i .= ',' . ($_[0] + 4) if $loose_indent;
return $i;
}
# Return visual length of a string, ignoring hyperlink markers.
# Markers are \x01<digits>\x02 (opening) and \x03 (closing).
sub visual_length
{
local $_ = shift;
s/\x01\d+\x02//g;
s/\x03//g;
return length;
}