[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * Pod-Simple-Texinfo/lib/Pod/Simple/Texinfo.pm (_
From: |
Patrice Dumas |
Subject: |
branch master updated: * Pod-Simple-Texinfo/lib/Pod/Simple/Texinfo.pm (_protect_text) (_prepend_internal_section_manual, _convert_pod): if not in code context in resulting Texinfo, protect -- and --- in order for the minus to be kept in the Texinfo output, as expected from Pod translators. This is important to avoid -- in options becoming ndash. |
Date: |
Tue, 08 Feb 2022 17:39:41 -0500 |
This is an automated email from the git hooks/post-receive script.
pertusus pushed a commit to branch master
in repository texinfo.
The following commit(s) were added to refs/heads/master by this push:
new f05762adf1 * Pod-Simple-Texinfo/lib/Pod/Simple/Texinfo.pm
(_protect_text) (_prepend_internal_section_manual, _convert_pod): if not in
code context in resulting Texinfo, protect -- and --- in order for the minus to
be kept in the Texinfo output, as expected from Pod translators. This is
important to avoid -- in options becoming ndash.
f05762adf1 is described below
commit f05762adf1575e574e6daf57bca13317b50c0ccd
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Tue Feb 8 23:39:30 2022 +0100
* Pod-Simple-Texinfo/lib/Pod/Simple/Texinfo.pm (_protect_text)
(_prepend_internal_section_manual, _convert_pod): if not in code
context in resulting Texinfo, protect -- and --- in order for the
minus to be kept in the Texinfo output, as expected from Pod
translators. This is important to avoid -- in options becoming
ndash.
---
ChangeLog | 9 ++++
Pod-Simple-Texinfo/lib/Pod/Simple/Texinfo.pm | 66 +++++++++++++++++++++-------
Pod-Simple-Texinfo/t/Pod-Simple-Texinfo.t | 19 +++++++-
doc/pod2texi.texi | 54 +++++++++++------------
4 files changed, 104 insertions(+), 44 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index c375f00b6e..ac95f882bf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2022-02-08 Patrice Dumas <pertusus@free.fr>
+
+ * Pod-Simple-Texinfo/lib/Pod/Simple/Texinfo.pm (_protect_text)
+ (_prepend_internal_section_manual, _convert_pod): if not in code
+ context in resulting Texinfo, protect -- and --- in order for the
+ minus to be kept in the Texinfo output, as expected from Pod
+ translators. This is important to avoid -- in options becoming
+ ndash.
+
2022-02-08 Patrice Dumas <pertusus@free.fr>
* contrib/perldoc-all, doc/texinfo.texi (Invoking @command{pod2texi}):
diff --git a/Pod-Simple-Texinfo/lib/Pod/Simple/Texinfo.pm
b/Pod-Simple-Texinfo/lib/Pod/Simple/Texinfo.pm
index 4dc423042c..3d0b417093 100644
--- a/Pod-Simple-Texinfo/lib/Pod/Simple/Texinfo.pm
+++ b/Pod-Simple-Texinfo/lib/Pod/Simple/Texinfo.pm
@@ -214,7 +214,7 @@ sub _preamble($)
}
}
if (defined($setfilename) and $setfilename =~ m/\S/) {
- $setfilename = _protect_text($setfilename, 1);
+ $setfilename = _protect_text($setfilename, 1, 1);
$setfilename .= '.info';
print $fh "\@setfilename $setfilename\n\n"
}
@@ -230,7 +230,7 @@ sub _preamble($)
} elsif (defined($self->texinfo_short_title())
and $self->texinfo_add_upper_sectioning_command()) {
my $level = $self->texinfo_sectioning_base_level() - 1;
- my $name = _protect_text($self->texinfo_short_title(), 1);
+ my $name = _protect_text($self->texinfo_short_title(), 1, 1);
my $node_name = _prepare_anchor($self, $name);
my $anchor = '';
@@ -282,13 +282,30 @@ sub _end_context($)
return ($previous_context->{'text'}, $previous_context->{'out'});
}
-sub _protect_text($;$)
+sub _protect_text($;$$)
{
my $text = shift;
my $remove_new_lines = shift;
+ my $in_code = shift;
cluck if (!defined($text));
$text =~ s/\n/ /g if ($remove_new_lines);
$text =~ s/([\@\{\}])/\@$1/g;
+ # from perlpodspec
+ # Pod parsers should not, by default, try to coerce apostrophe (') and quote
+ # (") into smart quotes (little 9's, 66's, 99's, etc), nor try to turn
+ # backtick (`) into anything else but a single backtick character (distinct
+ # from an open quote character!), nor "--" into anything but two minus signs.
+ # They must never do any of those things to text in C<...> formatting codes,
+ # and never ever to text in verbatim paragraphs.
+ #
+ # In Texinfo, -- --- would become dashes if not in verbatim/code. We make
+ # sure that it is not the case here. We do not do the same for the backticks
+ # and apostrophes, as there is no way to prevent those from becoming smart
+ # quotes without putting them in @code{} or similar @-command.
+ if (! $in_code) {
+ $text =~ s/---/\@asis{}-\@asis{}-\@asis{}-\@asis{}/g;
+ $text =~ s/--/\@asis{}-\@asis{}-\@asis{}/g
+ }
return $text;
}
@@ -331,14 +348,15 @@ sub _reference_to_text_in_texi($)
return Texinfo::Convert::Texinfo::convert_to_texinfo($tree);
}
-sub _prepend_internal_section_manual($$$)
+sub _prepend_internal_section_manual($$$;$)
{
my $manual = shift;
my $section = shift;
my $base_level = shift;
+ my $in_code = shift;
if (defined($manual) and $base_level > 0) {
- return _protect_text($manual, 1). " $section";
+ return _protect_text($manual, 1, $in_code). " $section";
} else {
return $section;
}
@@ -418,7 +436,7 @@ sub _node_name($$)
$texinfo_node_name
= _prepend_internal_section_manual($self->texinfo_short_title(),
$texinfo_node_name,
- $self->texinfo_sectioning_base_level());
+ $self->texinfo_sectioning_base_level(), 1);
# also change refs to text
return _reference_to_text_in_texi($texinfo_node_name);
}
@@ -563,7 +581,7 @@ sub _convert_pod($)
# but to be sure there is still a call to _protect_comma.
$url_arg = _protect_comma(_protect_text(
$self->texinfo_man_url_prefix()
-
."$section/"._url_escape($page)));
+ ."$section/"._url_escape($page),
0, 1));
} else {
$url_arg = '';
}
@@ -572,7 +590,7 @@ sub _convert_pod($)
} elsif ($linktype eq 'url') {
# NOTE: the .'' is here to force the $token->attr to be a real
# string and not an object.
- $url_arg = _protect_comma(_protect_text($token->attr('to').''));
+ $url_arg = _protect_comma(_protect_text($token->attr('to').'', 0,
1));
} elsif ($linktype eq 'pod') {
my $manual = $token->attr('to');
my $section = $token->attr('section');
@@ -599,9 +617,9 @@ sub _convert_pod($)
if ($self->{'texinfo_internal_pod_manuals_hash'}->{$manual}) {
$texinfo_node =
_prepend_internal_section_manual($manual, $section,
- $self->texinfo_sectioning_base_level());
+ $self->texinfo_sectioning_base_level(),
1);
} else {
- $texinfo_manual =
_protect_text(_pod_title_to_file_name($manual));
+ $texinfo_manual =
_protect_text(_pod_title_to_file_name($manual), 0, 1);
if (defined($section)) {
$texinfo_node = $section;
} else {
@@ -612,13 +630,14 @@ sub _convert_pod($)
$texinfo_node =
_prepend_internal_section_manual(
$self->texinfo_short_title(), $section,
- $self->texinfo_sectioning_base_level());
+ $self->texinfo_sectioning_base_level(),
1);
$texinfo_section = _normalize_texinfo_name(
_protect_comma(_protect_text($section)), 'section');
#print STDERR "L: internal: $texinfo_node/$texinfo_section\n";
}
$texinfo_node = _normalize_texinfo_name(
- _protect_comma(_protect_text($texinfo_node)), 'anchor');
+ # FIXME remove end of lines?
+ _protect_comma(_protect_text($texinfo_node, 0, 1)),
'anchor');
#print STDERR "L: normalized node: $texinfo_node\n";
# for pod, 'to' is the pod manual name. Then 'section' is the
@@ -636,6 +655,13 @@ sub _convert_pod($)
_begin_context(\@accumulated_output, $tagname);
} elsif ($tag_commands{$tagname}) {
_output($fh, \@accumulated_output, "\@$tag_commands{$tagname}\{");
+ if ($Texinfo::Common::code_style_commands{$tag_commands{$tagname}}) {
+ if (@format_stack and ref($format_stack[-1]) eq ''
+ and
defined($self->{'texinfo_raw_format_commands'}->{$format_stack[-1]})) {
+ cluck "in $format_stack[-1]: $tagname $tag_commands{$tagname}";
+ }
+ push @format_stack, 'in_code';
+ }
} elsif ($environment_commands{$tagname}) {
_output($fh, \@accumulated_output,
"\@$environment_commands{$tagname}\n");
if ($tagname eq 'Verbatim') {
@@ -654,22 +680,29 @@ sub _convert_pod($)
}
} elsif ($type eq 'text') {
my $text;
- if (@format_stack and !ref($format_stack[-1])
+ if (@format_stack and ref($format_stack[-1]) eq ''
and
((defined($self->{'texinfo_raw_format_commands'}->{$format_stack[-1]})
and
!$self->{'texinfo_raw_format_commands'}->{$format_stack[-1]})
or ($format_stack[-1] eq 'verbatim'))) {
$text = $token->text();
} else {
- $text = _protect_text($token->text());
- if (@format_stack and !ref($format_stack[-1])
+ if (@format_stack and ref($format_stack[-1]) eq ''
and ($self->{'texinfo_raw_format_commands'}->{$format_stack[-1]}))
{
+ $text = _protect_text($token->text(), 0, 1);
$text =~ s/^(\s*)#(\s*(line)? (\d+)((
"([^"]+)")(\s+\d+)*)?\s*)$/$1\@hashchar{}$2/mg;
+ } else {
+ $text = _protect_text($token->text(), 0,
+ (@format_stack and $format_stack[-1] eq 'in_code'));
}
}
_output($fh, \@accumulated_output, $text);
} elsif ($type eq 'end') {
my $tagname = $token->tagname();
if ($context_tags{$tagname}) {
+ # note that if the Pod command argument contains --- or -- they
+ # will already have been protected as text with -@asis{}-, so
+ # this will end up in the @anchor{} even if text protection
+ # is considered in code for the @anchor{}.
my ($result, $out) = _end_context(\@accumulated_output);
#print STDERR "end: $tagname: $result, $out\n";
my $texinfo_node = '';
@@ -783,6 +816,9 @@ sub _convert_pod($)
}
} elsif ($tag_commands{$tagname}) {
_output($fh, \@accumulated_output, "}");
+ if ($Texinfo::Common::code_style_commands{$tag_commands{$tagname}}) {
+ pop @format_stack;
+ }
} elsif ($environment_commands{$tagname}) {
if ($tagname eq 'Verbatim') {
pop @format_stack;
diff --git a/Pod-Simple-Texinfo/t/Pod-Simple-Texinfo.t
b/Pod-Simple-Texinfo/t/Pod-Simple-Texinfo.t
index b7b64ec860..5c3a82dec1 100644
--- a/Pod-Simple-Texinfo/t/Pod-Simple-Texinfo.t
+++ b/Pod-Simple-Texinfo/t/Pod-Simple-Texinfo.t
@@ -6,7 +6,7 @@
# change 'tests => 1' to 'tests => last_test_to_print';
use Test::More;
-BEGIN { plan tests => 17 };
+BEGIN { plan tests => 18 };
use Pod::Simple::Texinfo;
ok(1); # If we made it this far, we're ok.
@@ -84,7 +84,7 @@ T@c
T@@c
@node T@@c @@@{@}
-@section T@@c @@@{@}
+@section @@@{@}
@node T@@c @@@comma{}
@subsection @@,
@@ -319,5 +319,20 @@ run_test('=head1 head
@end html
','cpp lines in formats');
+run_test('=head1 ---- -- C<--->
+
+C<--- L<---|--/--->>
+
+L<F<--->|F<-->/C<--->>
+
+','@chapter @asis{}-@asis{}-@asis{}-@asis{}- @asis{}-@asis{}-@asis{} @code{---}
+@anchor{@asis{}-@asis{}-@asis{}-@asis{}- @asis{}-@asis{}-@asis{} @code{---}}
+
+@code{--- @ref{---, @asis{}-@asis{}-@asis{}-@asis{},, --}}
+
+@ref{---, @file{---},, --}
+
+', 'protected -');
+
1;
diff --git a/doc/pod2texi.texi b/doc/pod2texi.texi
index 12ee5296d0..94f6d73e18 100644
--- a/doc/pod2texi.texi
+++ b/doc/pod2texi.texi
@@ -28,15 +28,15 @@ and all the @code{@@include} is generated.
@anchor{pod2texi OPTIONS}
@table @asis
-@item @strong{--appendix-sections}
-@anchor{pod2texi @strong{--appendix-sections}}
+@item @strong{@asis{}-@asis{}-@asis{}appendix-sections}
+@anchor{pod2texi @strong{@asis{}-@asis{}-@asis{}appendix-sections}}
Use appendix sectioning commands (@code{@@appendix}, ...) instead of the
default numbered sectioning Texinfo @@-commands (@code{@@chapter},
@code{@@section}, ...).
-@item @strong{--base-level}=@emph{NUM|NAME}
-@anchor{pod2texi @strong{--base-level}=@emph{NUM|NAME}}
+@item @strong{@asis{}-@asis{}-@asis{}base-level}=@emph{NUM|NAME}
+@anchor{pod2texi @strong{@asis{}-@asis{}-@asis{}base-level}=@emph{NUM|NAME}}
Sets the level of the @code{head1} commands. It may be an integer or a
Texinfo sectioning command (without the @code{@@}): 1 corresponds to the
@@ -54,69 +54,69 @@ For an example of making Texinfo out of the Perl
documentation itself,
see @code{contrib/perldoc-all} in the Texinfo source distribution, with
output available at @url{http://www.gnu.org/software/perl/manual}.
-@item @strong{--debug}=@emph{NUM}
-@anchor{pod2texi @strong{--debug}=@emph{NUM}}
+@item @strong{@asis{}-@asis{}-@asis{}debug}=@emph{NUM}
+@anchor{pod2texi @strong{@asis{}-@asis{}-@asis{}debug}=@emph{NUM}}
Set debugging level to @emph{NUM}.
-@item @strong{--headings-as-sections}
-@anchor{pod2texi @strong{--headings-as-sections}}
+@item @strong{@asis{}-@asis{}-@asis{}headings-as-sections}
+@anchor{pod2texi @strong{@asis{}-@asis{}-@asis{}headings-as-sections}}
Use headings commands (@code{@@heading}, ...) instead of the
default numbered sectioning Texinfo @@-commands (@code{@@chapter},
@code{@@section}, ...). The sectioning command covering the entire
-file output for each Pod file if @strong{--base-level} is not 0 is a
+file output for each Pod file if @strong{@asis{}-@asis{}-@asis{}base-level} is
not 0 is a
numbered command.
-@item @strong{--help}
-@anchor{pod2texi @strong{--help}}
+@item @strong{@asis{}-@asis{}-@asis{}help}
+@anchor{pod2texi @strong{@asis{}-@asis{}-@asis{}help}}
Display help and exit.
-@item @strong{--output}=@emph{NAME}
-@anchor{pod2texi @strong{--output}=@emph{NAME}}
+@item @strong{@asis{}-@asis{}-@asis{}output}=@emph{NAME}
+@anchor{pod2texi @strong{@asis{}-@asis{}-@asis{}output}=@emph{NAME}}
Name for the first manual, or the main manual if there is a main manual.
Default is to write to standard output.
-@item @strong{--no-section-nodes}
-@anchor{pod2texi @strong{--no-section-nodes}}
+@item @strong{@asis{}-@asis{}-@asis{}no-section-nodes}
+@anchor{pod2texi @strong{@asis{}-@asis{}-@asis{}no-section-nodes}}
Use anchors for sections instead of nodes.
-@item @strong{--no-fill-section-gaps}
-@anchor{pod2texi @strong{--no-fill-section-gaps}}
+@item @strong{@asis{}-@asis{}-@asis{}no-fill-section-gaps}
+@anchor{pod2texi @strong{@asis{}-@asis{}-@asis{}no-fill-section-gaps}}
Do not fill sectioning gaps with empty @code{@@unnumbered} files.
Ordinarily, it's good to keep the sectioning hierarchy intact.
-@item @strong{--preamble}=@emph{STR}
-@anchor{pod2texi @strong{--preamble}=@emph{STR}}
+@item @strong{@asis{}-@asis{}-@asis{}preamble}=@emph{STR}
+@anchor{pod2texi @strong{@asis{}-@asis{}-@asis{}preamble}=@emph{STR}}
Insert @emph{STR} as top boilerplate before menu and includes. If @emph{STR}
is
set to @code{-}, read the top boilerplate from the standard input. The
default top
boilerplate is a minimal beginning for a Texinfo document.
-@item @strong{--subdir}=@emph{NAME}
-@anchor{pod2texi @strong{--subdir}=@emph{NAME}}
+@item @strong{@asis{}-@asis{}-@asis{}subdir}=@emph{NAME}
+@anchor{pod2texi @strong{@asis{}-@asis{}-@asis{}subdir}=@emph{NAME}}
If there is a main manual with include files (each corresponding to
an input Pod file), then those include files are put in directory @emph{NAME}.
-@item @strong{--unnumbered-sections}
-@anchor{pod2texi @strong{--unnumbered-sections}}
+@item @strong{@asis{}-@asis{}-@asis{}unnumbered-sections}
+@anchor{pod2texi @strong{@asis{}-@asis{}-@asis{}unnumbered-sections}}
Use unnumbered sectioning commands (@code{@@unnumbered}, ...) instead of the
default numbered sectioning Texinfo @@-commands (@code{@@chapter},
@code{@@section}, ...).
-@item @strong{--top}=@emph{TOP}
-@anchor{pod2texi @strong{--top}=@emph{TOP}}
+@item @strong{@asis{}-@asis{}-@asis{}top}=@emph{TOP}
+@anchor{pod2texi @strong{@asis{}-@asis{}-@asis{}top}=@emph{TOP}}
Name of the @code{@@top} element for the main manual. May contain Texinfo
code.
-@item @strong{--version}
-@anchor{pod2texi @strong{--version}}
+@item @strong{@asis{}-@asis{}-@asis{}version}
+@anchor{pod2texi @strong{@asis{}-@asis{}-@asis{}version}}
Display version information and exit.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * Pod-Simple-Texinfo/lib/Pod/Simple/Texinfo.pm (_protect_text) (_prepend_internal_section_manual, _convert_pod): if not in code context in resulting Texinfo, protect -- and --- in order for the minus to be kept in the Texinfo output, as expected from Pod translators. This is important to avoid -- in options becoming ndash.,
Patrice Dumas <=