[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
texinfo/tp Texinfo/Parser.pm Texinfo/Convert/Co...
From: |
Patrice Dumas |
Subject: |
texinfo/tp Texinfo/Parser.pm Texinfo/Convert/Co... |
Date: |
Sun, 20 Jan 2013 16:45:29 +0000 |
CVSROOT: /sources/texinfo
Module name: texinfo
Changes by: Patrice Dumas <pertusus> 13/01/20 16:45:29
Modified files:
tp/Texinfo : Parser.pm
tp/Texinfo/Convert: Converter.pm
tp/t : 50value.t
Added files:
tp/t/results/value: set_flag_command_equivalent.pl
Log message:
Replace @set txicodequoteundirected/txicodequotebacktick with
@codequoteundirected/@codequotebacktick directly in the tree.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Parser.pm?cvsroot=texinfo&r1=1.410&r2=1.411
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Converter.pm?cvsroot=texinfo&r1=1.97&r2=1.98
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/50value.t?cvsroot=texinfo&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/value/set_flag_command_equivalent.pl?cvsroot=texinfo&rev=1.1
Patches:
Index: Texinfo/Parser.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Parser.pm,v
retrieving revision 1.410
retrieving revision 1.411
diff -u -b -r1.410 -r1.411
--- Texinfo/Parser.pm 7 Jan 2013 21:42:13 -0000 1.410
+++ Texinfo/Parser.pm 20 Jan 2013 16:45:28 -0000 1.411
@@ -239,6 +239,14 @@
my %inline_format_commands = %Texinfo::Common::inline_format_commands;
my %all_commands = %Texinfo::Common::all_commands;
+# equivalence between a @set flag and an @@-command
+my %set_flag_command_equivalent = (
+ 'txicodequoteundirected' => 'codequoteundirected',
+ 'txicodequotebacktick' => 'codequotebacktick',
+# 'txideftypefnnl' => 'deftypefnnewline',
+);
+
+
# keep line information for those commands.
my %keep_line_nr_brace_commands = %context_brace_commands;
foreach my $keep_line_nr_brace_command ('titlefont', 'anchor') {
@@ -4234,7 +4242,6 @@
}
$misc = {'cmdname' => $command,
'parent' => $current};
- push @{$current->{'contents'}}, $misc;
my $args = [];
if ($arg_spec eq 'lineraw' or $arg_spec eq 'skipline') {
$args = [ $line ];
@@ -4243,11 +4250,51 @@
= $self->_parse_special_misc_command($line, $command,
$line_nr);
$misc->{'extra'}->{'arg_line'} = $line;
}
+
+ # if using the @set txi* instead of a proper @-command, replace
+ # by the tree obtained with the @-command. Even though
+ # _end_line is called below, as $current is not misc_line_arg
+ # there should not be anything done in addition than what is
+ # done for @clear or @set.
+ if (($command eq 'set' or $command eq 'clear')
+ and scalar(@$args) >= 1
+ and $set_flag_command_equivalent{$args->[0]}) {
+ my $arg;
+ if ($command eq 'set') {
+ $arg = 'on';
+ } else {
+ $arg = 'off';
+ }
+ $command = $set_flag_command_equivalent{$args->[0]};
+ $misc = {'cmdname' => $command,
+ 'parent' => $current,
+ 'line_nr' => $line_nr,
+ 'extra' => {'misc_args' => [$arg]}};
+ my $misc_line_args = {'type' => 'misc_line_arg',
+ 'parent' => $misc};
+ $misc->{'args'} = [$misc_line_args];
+ my $spaces_after_command
+ = { 'type' => 'empty_spaces_after_command',
+ 'text' => ' ',
+ 'parent' => $misc_line_args,
+ 'extra' => {'command' => $misc} };
+ $misc->{'extra'}->{'spaces_after_command'}
+ = $spaces_after_command;
+ $misc_line_args->{'contents'} = [ $spaces_after_command,
+ { 'text' => $arg,
+ 'parent' => $misc_line_args, },
+ { 'text' => "\n",
+ 'parent' => $misc_line_args,
+ 'type' => 'spaces_at_end', } ];
+ push @{$current->{'contents'}}, $misc;
+ } else {
+ push @{$current->{'contents'}}, $misc;
foreach my $arg (@$args) {
push @{$misc->{'args'}},
{ 'type' => 'misc_arg', 'text' => $arg,
'parent' => $current->{'contents'}->[-1] };
}
+ }
if ($command eq 'raisesections') {
$self->{'sections_level'}++;
} elsif ($command eq 'lowersections') {
@@ -4258,10 +4305,10 @@
$self->_register_and_warn_invalid($command, $invalid_parent,
$line_nr, $misc);
$self->_register_global_command($command, $misc, $line_nr);
- $current = _end_line ($self, $current, $line_nr);
+ $current = _end_line($self, $current, $line_nr);
last NEXT_LINE if ($command eq 'bye');
- # This is not done in _end_line is there is no misc_line_arg
+ # This is not done in _end_line as there is no misc_line_arg
$current = $self->_begin_preformatted($current)
if ($close_preformatted_commands{$command});
last;
Index: Texinfo/Convert/Converter.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Converter.pm,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -b -r1.97 -r1.98
--- Texinfo/Convert/Converter.pm 15 Jan 2013 01:25:51 -0000 1.97
+++ Texinfo/Convert/Converter.pm 20 Jan 2013 16:45:28 -0000 1.98
@@ -861,11 +861,11 @@
if ($elements) {
my $result = '';
foreach my $element (@$elements) {
- $result .= $self->_output_text ($self->convert_tree($element), $fh);
+ $result .= $self->_output_text($self->convert_tree($element), $fh);
}
return $result;
} else {
- return $self->_output_text ($self->convert_tree($root), $fh);
+ return $self->_output_text($self->convert_tree($root), $fh);
}
}
Index: t/50value.t
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/50value.t,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- t/50value.t 20 Nov 2012 01:49:29 -0000 1.15
+++ t/50value.t 20 Jan 2013 16:45:29 -0000 1.16
@@ -273,6 +273,13 @@
['value_in_invalid_documentencoding',
'@set badvalue bad
@documentencoding @value{badvalue}
+'],
+['set_flag_command_equivalent',
+'@set txicodequoteundirected
+
address@hidden
+
address@hidden txicodequoteundirected
']
);
Index: t/results/value/set_flag_command_equivalent.pl
===================================================================
RCS file: t/results/value/set_flag_command_equivalent.pl
diff -N t/results/value/set_flag_command_equivalent.pl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ t/results/value/set_flag_command_equivalent.pl 20 Jan 2013 16:45:29
-0000 1.1
@@ -0,0 +1,153 @@
+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);
+
+use utf8;
+
+$result_trees{'set_flag_command_equivalent'} = {
+ 'contents' => [
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'extra' => {
+ 'command' => {}
+ },
+ 'parent' => {},
+ 'text' => ' ',
+ 'type' => 'empty_spaces_after_command'
+ },
+ {
+ 'parent' => {},
+ 'text' => 'on'
+ },
+ {
+ 'parent' => {},
+ 'text' => '
+',
+ 'type' => 'spaces_at_end'
+ }
+ ],
+ 'parent' => {},
+ 'type' => 'misc_line_arg'
+ }
+ ],
+ 'cmdname' => 'codequoteundirected',
+ 'extra' => {
+ 'misc_args' => [
+ 'on'
+ ],
+ 'spaces_after_command' => {}
+ },
+ 'line_nr' => {
+ 'file_name' => '',
+ 'line_nr' => 1,
+ 'macro' => ''
+ },
+ 'parent' => {}
+ },
+ {
+ 'parent' => {},
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
+ {
+ 'contents' => [
+ {
+ 'parent' => {},
+ 'text' => '.
+'
+ }
+ ],
+ 'parent' => {},
+ 'type' => 'paragraph'
+ },
+ {
+ 'parent' => {},
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'extra' => {
+ 'command' => {}
+ },
+ 'parent' => {},
+ 'text' => ' ',
+ 'type' => 'empty_spaces_after_command'
+ },
+ {
+ 'parent' => {},
+ 'text' => 'off'
+ },
+ {
+ 'parent' => {},
+ 'text' => '
+',
+ 'type' => 'spaces_at_end'
+ }
+ ],
+ 'parent' => {},
+ 'type' => 'misc_line_arg'
+ }
+ ],
+ 'cmdname' => 'codequoteundirected',
+ 'extra' => {
+ 'misc_args' => [
+ 'off'
+ ],
+ 'spaces_after_command' => {}
+ },
+ 'line_nr' => {
+ 'file_name' => '',
+ 'line_nr' => 5,
+ 'macro' => ''
+ },
+ 'parent' => {}
+ }
+ ],
+ 'type' => 'text_root'
+};
+$result_trees{'set_flag_command_equivalent'}{'contents'}[0]{'args'}[0]{'contents'}[0]{'extra'}{'command'}
= $result_trees{'set_flag_command_equivalent'}{'contents'}[0];
+$result_trees{'set_flag_command_equivalent'}{'contents'}[0]{'args'}[0]{'contents'}[0]{'parent'}
= $result_trees{'set_flag_command_equivalent'}{'contents'}[0]{'args'}[0];
+$result_trees{'set_flag_command_equivalent'}{'contents'}[0]{'args'}[0]{'contents'}[1]{'parent'}
= $result_trees{'set_flag_command_equivalent'}{'contents'}[0]{'args'}[0];
+$result_trees{'set_flag_command_equivalent'}{'contents'}[0]{'args'}[0]{'contents'}[2]{'parent'}
= $result_trees{'set_flag_command_equivalent'}{'contents'}[0]{'args'}[0];
+$result_trees{'set_flag_command_equivalent'}{'contents'}[0]{'args'}[0]{'parent'}
= $result_trees{'set_flag_command_equivalent'}{'contents'}[0];
+$result_trees{'set_flag_command_equivalent'}{'contents'}[0]{'extra'}{'spaces_after_command'}
=
$result_trees{'set_flag_command_equivalent'}{'contents'}[0]{'args'}[0]{'contents'}[0];
+$result_trees{'set_flag_command_equivalent'}{'contents'}[0]{'parent'} =
$result_trees{'set_flag_command_equivalent'};
+$result_trees{'set_flag_command_equivalent'}{'contents'}[1]{'parent'} =
$result_trees{'set_flag_command_equivalent'};
+$result_trees{'set_flag_command_equivalent'}{'contents'}[2]{'contents'}[0]{'parent'}
= $result_trees{'set_flag_command_equivalent'}{'contents'}[2];
+$result_trees{'set_flag_command_equivalent'}{'contents'}[2]{'parent'} =
$result_trees{'set_flag_command_equivalent'};
+$result_trees{'set_flag_command_equivalent'}{'contents'}[3]{'parent'} =
$result_trees{'set_flag_command_equivalent'};
+$result_trees{'set_flag_command_equivalent'}{'contents'}[4]{'args'}[0]{'contents'}[0]{'extra'}{'command'}
= $result_trees{'set_flag_command_equivalent'}{'contents'}[4];
+$result_trees{'set_flag_command_equivalent'}{'contents'}[4]{'args'}[0]{'contents'}[0]{'parent'}
= $result_trees{'set_flag_command_equivalent'}{'contents'}[4]{'args'}[0];
+$result_trees{'set_flag_command_equivalent'}{'contents'}[4]{'args'}[0]{'contents'}[1]{'parent'}
= $result_trees{'set_flag_command_equivalent'}{'contents'}[4]{'args'}[0];
+$result_trees{'set_flag_command_equivalent'}{'contents'}[4]{'args'}[0]{'contents'}[2]{'parent'}
= $result_trees{'set_flag_command_equivalent'}{'contents'}[4]{'args'}[0];
+$result_trees{'set_flag_command_equivalent'}{'contents'}[4]{'args'}[0]{'parent'}
= $result_trees{'set_flag_command_equivalent'}{'contents'}[4];
+$result_trees{'set_flag_command_equivalent'}{'contents'}[4]{'extra'}{'spaces_after_command'}
=
$result_trees{'set_flag_command_equivalent'}{'contents'}[4]{'args'}[0]{'contents'}[0];
+$result_trees{'set_flag_command_equivalent'}{'contents'}[4]{'parent'} =
$result_trees{'set_flag_command_equivalent'};
+
+$result_texis{'set_flag_command_equivalent'} = '@codequoteundirected on
+
+.
+
address@hidden off
+';
+
+
+$result_texts{'set_flag_command_equivalent'} = '
+.
+
+';
+
+$result_errors{'set_flag_command_equivalent'} = [];
+
+
+1;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- texinfo/tp Texinfo/Parser.pm Texinfo/Convert/Co...,
Patrice Dumas <=