[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/Common.pm (_informative_command_valu
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/Common.pm (_informative_command_value): get information for line commands of type line, using the first args contents if it is text. |
Date: |
Thu, 29 Dec 2022 05:11:04 -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 0da70eca6c * tp/Texinfo/Common.pm (_informative_command_value): get
information for line commands of type line, using the first args contents if it
is text.
0da70eca6c is described below
commit 0da70eca6cf5da82e91bea5af610730ca5db9b06
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Thu Dec 29 11:09:50 2022 +0100
* tp/Texinfo/Common.pm (_informative_command_value): get information
for line commands of type line, using the first args contents if it is
text.
* tp/Texinfo/Common.pm (set_informative_command_value),
tp/Texinfo/Convert/LaTeX.pm (_convert): add a return
status from set_informative_command_value(), true if the customization
variable was set. Output code related to a command associated to a
customization variable in LaTeX only if the customization variable
was set.
* tp/Texinfo/Config.pm (set_conf), tp/Texinfo/Convert/Text.pm
(set_conf): add a return status for consistency with
Texinfo::Convert:Converter set_conf.
* tp/t/latex_tests.t: add
setchapternewpage_on_odd_titlepage_set_headings test, with headings
customization variable set.
---
ChangeLog | 21 ++
tp/Texinfo/Common.pm | 29 ++-
tp/Texinfo/Config.pm | 2 +
tp/Texinfo/Convert/Converter.pm | 5 +-
tp/Texinfo/Convert/LaTeX.pm | 10 +-
tp/Texinfo/Convert/Text.pm | 2 +
tp/t/latex_tests.t | 11 +
...chapternewpage_on_odd_titlepage_set_headings.pl | 248 +++++++++++++++++++++
8 files changed, 313 insertions(+), 15 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a5affe9ed7..5f999d6be5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2022-12-29 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Common.pm (_informative_command_value): get information
+ for line commands of type line, using the first args contents if it is
+ text.
+
+ * tp/Texinfo/Common.pm (set_informative_command_value),
+ tp/Texinfo/Convert/LaTeX.pm (_convert): add a return
+ status from set_informative_command_value(), true if the customization
+ variable was set. Output code related to a command associated to a
+ customization variable in LaTeX only if the customization variable
+ was set.
+
+ * tp/Texinfo/Config.pm (set_conf), tp/Texinfo/Convert/Text.pm
+ (set_conf): add a return status for consistency with
+ Texinfo::Convert:Converter set_conf.
+
+ * tp/t/latex_tests.t: add
+ setchapternewpage_on_odd_titlepage_set_headings test, with headings
+ customization variable set.
+
2022-12-29 Gavin Smith <gavinsmith0123@gmail.com>
* doc/texinfo.texi (@cartouche): Do not use @emph inside
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index ff56aa40cc..aa172a626e 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -150,7 +150,7 @@ my %default_parser_specific_customization = (
'MAX_MACRO_CALL_NESTING' => 100000, # max number of nested macro calls
);
-# this serves both to set defaults and list configuration options
+# this serves both to set defaults and list customization variable
# valid for the parser.
# also used in util/txicustomvars
our %default_parser_customization_values =
(%default_parser_common_customization,
@@ -198,7 +198,7 @@ our %document_settable_unique_at_commands = (
'afourlatex' => undef,
'afourwide' => undef,
'bsixpaper' => undef,
- # when passed through a configuration variable, documentdescription
+ # when passed through a customization variable, documentdescription
# should be already formatted for HTML. There is no default,
# what is determined to be the title is used if not set.
'documentdescription' => undef,
@@ -1203,6 +1203,13 @@ sub _informative_command_value($)
} elsif ($element->{'extra'} and $element->{'extra'}->{'misc_args'}
and exists($element->{'extra'}->{'misc_args'}->[0])) {
return $element->{'extra'}->{'misc_args'}->[0];
+ } elsif ($Texinfo::Commands::line_commands{$cmdname} eq 'line'
+ and $element->{'args'} and scalar(@{$element->{'args'}})
+ and $element->{'args'}->[0]
+ and $element->{'args'}->[0]->{'contents'}
+ and scalar(@{$element->{'args'}->[0]->{'contents'}})
+ and exists($element->{'args'}->[0]->{'contents'}->[0]->{'text'})) {
+ return $element->{'args'}->[0]->{'contents'}->[0]->{'text'};
}
return undef;
}
@@ -1220,8 +1227,9 @@ sub set_informative_command_value($$)
my $value = _informative_command_value($element);
if (defined($value)) {
- $self->set_conf($cmdname, $value);
+ return $self->set_conf($cmdname, $value);
}
+ return 0;
}
sub _in_preamble($)
@@ -2673,7 +2681,7 @@ raise/lowersections.
=item $element = set_global_document_command($customization_information,
$global_commands_information, $cmdname, $command_location)
X<C<set_global_document_command>>
-Set the Texinfo configuration option corresponding to I<$cmdname> in
+Set the Texinfo customization variable corresponding to I<$cmdname> in
I<$customization_information>. The I<$global_commands_information> should
contain information about global commands in a Texinfo document, typically
obtained
from a parser L<<
$parser->global_commands_information()|Texinfo::Parser/$commands =
global_commands_information($parser) >>.
@@ -2699,19 +2707,20 @@ sequentially to the values in the Texinfo preamble.
=back
The I<$element> returned is the last element that was used to set the
-configuration value, or C<undef> if no configuration value was found.
+customization value, or C<undef> if no customization value was found.
Notice that the only effect of this function is to set a customization
variable value, no @-command side effects are run, no associated customization
variables are set.
-=item set_informative_command_value($customization_information, $element)
+=item $status = set_informative_command_value($customization_information,
$element)
X<C<set_informative_command_value>>
-Set the Texinfo configuration option corresponding to the tree element
+Set the Texinfo customization option corresponding to the tree element
I<$element>. The command associated to the tree element should be
a command that sets some information, such as C<@documentlanguage>,
-C<@contents> or C<@footnotestyle> for example.
+C<@contents> or C<@footnotestyle> for example. Return true if the command
+argument was found and the customization variable was set.
=item set_output_encodings($customization_information, $parser_information)
X<C<set_output_encodings>>
@@ -2736,12 +2745,12 @@ X<C<trim_spaces_comment_from_content>>
Remove empty spaces after commands or braces at begin and
spaces and comments at end from a content array, modifying it.
-=item valid_customization_option($name)
+=item $status = valid_customization_option($name)
X<C<valid_option>>
Return true if the I<$name> is a known customization option.
-=item valid_tree_transformation($name)
+=item $status = valid_tree_transformation($name)
X<C<valid_tree_transformation>>
Return true if the I<$name> is a known tree transformation name
diff --git a/tp/Texinfo/Config.pm b/tp/Texinfo/Config.pm
index 1acedd33e4..2f5149e0e0 100644
--- a/tp/Texinfo/Config.pm
+++ b/tp/Texinfo/Config.pm
@@ -829,6 +829,8 @@ sub set_conf($$$)
my $var = shift;
my $val = shift;
$self->{'config'}->{$var} = $val;
+
+ return 1;
}
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index 2e1049c2c2..b1a5cf5baa 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -1897,11 +1897,12 @@ X<C<get_conf>>
Returns the value of the Texinfo customization variable I<$variable_name>.
-=item $converter->set_conf($variable_name, $variable_value)
+=item $status = $converter->set_conf($variable_name, $variable_value)
X<C<set_conf>>
Set the Texinfo customization option I<$variable_name> to I<$variable_value> if
-not set as a converter option.
+not set as a converter option. Returns false if the customization options
+was not set.
=back
diff --git a/tp/Texinfo/Convert/LaTeX.pm b/tp/Texinfo/Convert/LaTeX.pm
index 833bb6e71d..b21a8659d2 100644
--- a/tp/Texinfo/Convert/LaTeX.pm
+++ b/tp/Texinfo/Convert/LaTeX.pm
@@ -1634,8 +1634,8 @@ sub _latex_begin_output($)
$header .= $setchapternewpage_result;
}
my $heading = $self->get_conf('headings');
- if (defined($heading) and ((!defined($heading_set)
- or $heading_set ne $heading))) {
+ if (defined($heading) and (not defined($heading_set)
+ or $heading_set ne $heading)) {
$header .= _set_headings($self, $heading);
}
$header .= "\n";
@@ -3793,8 +3793,11 @@ sub _convert($$)
# @-commands that have an information for the formatting
} elsif ($informative_commands{$cmdname}) {
- Texinfo::Common::set_informative_command_value($self, $element);
+ my $set = Texinfo::Common::set_informative_command_value($self,
$element);
+ if (not $set) {
+ return $result;
+ }
if ($cmdname eq 'documentlanguage') {
my $language = $self->get_conf('documentlanguage');
$language =~ s/_/-/;
@@ -3802,6 +3805,7 @@ sub _convert($$)
$self->{'packages'}->{'babel'} = 1;
} elsif ($cmdname eq 'pagesizes') {
my $pagesize_spec = _convert($self, $element->{'args'}->[0]);
+ #my $pagesize_spec = $self->get_conf('pagesizes');
my @pagesize_args = split(/\s*,\s*/, $pagesize_spec);
my @geometry;
my $height = shift @pagesize_args;
diff --git a/tp/Texinfo/Convert/Text.pm b/tp/Texinfo/Convert/Text.pm
index 69a0c83fc9..4060c7fac7 100644
--- a/tp/Texinfo/Convert/Text.pm
+++ b/tp/Texinfo/Convert/Text.pm
@@ -872,6 +872,8 @@ sub set_conf($$$)
my $value = shift;
$self->{$conf} = $value;
+
+ return 1;
}
sub errors()
diff --git a/tp/t/latex_tests.t b/tp/t/latex_tests.t
index 434a9f56e2..5d3969eb07 100644
--- a/tp/t/latex_tests.t
+++ b/tp/t/latex_tests.t
@@ -229,6 +229,17 @@ in titlepage
in titlepage
@end titlepage
'],
+['setchapternewpage_on_odd_titlepage_set_headings',
+'@setchapternewpage on
+
+@setchapternewpage odd
+
+@titlepage
+in titlepage
+@end titlepage
+
+@headings off
+', {}, {'headings' => 'singleafter'}],
['custom_headings',
'
@evenheading @thispage @thissectionname @| @thissectionnum @thissection @|
@thischaptername @thischapternum
diff --git
a/tp/t/results/latex_tests/setchapternewpage_on_odd_titlepage_set_headings.pl
b/tp/t/results/latex_tests/setchapternewpage_on_odd_titlepage_set_headings.pl
new file mode 100644
index 0000000000..8ff1d5e0c5
--- /dev/null
+++
b/tp/t/results/latex_tests/setchapternewpage_on_odd_titlepage_set_headings.pl
@@ -0,0 +1,248 @@
+use vars qw(%result_texis %result_texts %result_trees %result_errors
+ %result_indices %result_sectioning %result_nodes %result_menus
+ %result_floats %result_converted %result_converted_errors
+ %result_elements %result_directions_text %result_indices_sort_strings);
+
+use utf8;
+
+$result_trees{'setchapternewpage_on_odd_titlepage_set_headings'} = {
+ 'contents' => [
+ {
+ 'contents' => [
+ {
+ 'contents' => [
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'on'
+ }
+ ],
+ 'info' => {
+ 'spaces_after_argument' => '
+'
+ },
+ 'type' => 'line_arg'
+ }
+ ],
+ 'cmdname' => 'setchapternewpage',
+ 'extra' => {
+ 'misc_args' => [
+ 'on'
+ ]
+ },
+ 'info' => {
+ 'spaces_before_argument' => ' '
+ },
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 1,
+ 'macro' => ''
+ }
+ },
+ {
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'odd'
+ }
+ ],
+ 'info' => {
+ 'spaces_after_argument' => '
+'
+ },
+ 'type' => 'line_arg'
+ }
+ ],
+ 'cmdname' => 'setchapternewpage',
+ 'extra' => {
+ 'misc_args' => [
+ 'odd'
+ ]
+ },
+ 'info' => {
+ 'spaces_before_argument' => ' '
+ },
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 3,
+ 'macro' => ''
+ }
+ },
+ {
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
+ {
+ 'args' => [
+ {
+ 'info' => {
+ 'spaces_after_argument' => '
+'
+ },
+ 'type' => 'block_line_arg'
+ }
+ ],
+ 'cmdname' => 'titlepage',
+ 'contents' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'in titlepage
+'
+ }
+ ],
+ 'type' => 'paragraph'
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'titlepage'
+ }
+ ],
+ 'info' => {
+ 'spaces_after_argument' => '
+'
+ },
+ 'type' => 'line_arg'
+ }
+ ],
+ 'cmdname' => 'end',
+ 'extra' => {
+ 'text_arg' => 'titlepage'
+ },
+ 'info' => {
+ 'spaces_before_argument' => ' '
+ },
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 7,
+ 'macro' => ''
+ }
+ }
+ ],
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 5,
+ 'macro' => ''
+ }
+ },
+ {
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'off'
+ }
+ ],
+ 'info' => {
+ 'spaces_after_argument' => '
+'
+ },
+ 'type' => 'line_arg'
+ }
+ ],
+ 'cmdname' => 'headings',
+ 'extra' => {
+ 'misc_args' => [
+ 'off'
+ ]
+ },
+ 'info' => {
+ 'spaces_before_argument' => ' '
+ },
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 9,
+ 'macro' => ''
+ }
+ }
+ ],
+ 'type' => 'preamble_before_content'
+ }
+ ],
+ 'type' => 'before_node_section'
+ }
+ ],
+ 'type' => 'document_root'
+};
+
+$result_texis{'setchapternewpage_on_odd_titlepage_set_headings'} =
'@setchapternewpage on
+
+@setchapternewpage odd
+
+@titlepage
+in titlepage
+@end titlepage
+
+@headings off
+';
+
+
+$result_texts{'setchapternewpage_on_odd_titlepage_set_headings'} = '
+
+
+';
+
+$result_errors{'setchapternewpage_on_odd_titlepage_set_headings'} = [
+ {
+ 'error_line' => 'warning: multiple @setchapternewpage
+',
+ 'file_name' => '',
+ 'line_nr' => 3,
+ 'macro' => '',
+ 'text' => 'multiple @setchapternewpage',
+ 'type' => 'warning'
+ }
+];
+
+
+$result_floats{'setchapternewpage_on_odd_titlepage_set_headings'} = {};
+
+
+
+$result_converted{'latex_text'}->{'setchapternewpage_on_odd_titlepage_set_headings'}
= '\\makeatletter
+\\patchcmd{\\chapter}{\\if@openright\\cleardoublepage\\else\\clearpage\\fi}{\\Texinfoplaceholder{setchapternewpage
placeholder}\\clearpage}{}{}
+\\makeatother
+\\pagestyle{single}%
+
+\\makeatletter
+\\patchcmd{\\chapter}{\\Texinfoplaceholder{setchapternewpage
placeholder}\\clearpage}{\\if@openright\\cleardoublepage\\else\\clearpage\\fi}{}{}
+\\makeatother
+\\pagestyle{double}%
+
+
+\\begin{document}
+
+\\frontmatter
+\\pagestyle{empty}%
+\\begin{titlepage}
+\\begingroup
+\\newskip\\titlepagetopglue \\titlepagetopglue = 1.5in
+\\newskip\\titlepagebottomglue \\titlepagebottomglue = 2pc
+\\setlength{\\parindent}{0pt}
+% Leave some space at the very top of the page.
+ \\vglue\\titlepagetopglue
+in titlepage
+\\endgroup
+\\end{titlepage}
+\\mainmatter
+\\pagestyle{single}%
+';
+
+1;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/Common.pm (_informative_command_value): get information for line commands of type line, using the first args contents if it is text.,
Patrice Dumas <=