[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
texinfo/tp TODO texi2any.pl Texinfo/Convert/Tex...
From: |
Patrice Dumas |
Subject: |
texinfo/tp TODO texi2any.pl Texinfo/Convert/Tex... |
Date: |
Wed, 02 Nov 2011 23:08:18 +0000 |
CVSROOT: /sources/texinfo
Module name: texinfo
Changes by: Patrice Dumas <pertusus> 11/11/02 23:08:18
Modified files:
tp : TODO texi2any.pl
tp/Texinfo/Convert: Text.pm
tp/t/results/quotation: empty_quotation.pl
only_comment_on_quotation_line.pl
tp/t/results/xml_tests: comments_on_block_command_lines.pl
Log message:
Implement the converters API for Convert::Text, but as simply as
possible.
Handle rightly end of line of @quotations without argument with comment.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/TODO?cvsroot=texinfo&r1=1.204&r2=1.205
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/texi2any.pl?cvsroot=texinfo&r1=1.81&r2=1.82
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Text.pm?cvsroot=texinfo&r1=1.76&r2=1.77
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/quotation/empty_quotation.pl?cvsroot=texinfo&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/quotation/only_comment_on_quotation_line.pl?cvsroot=texinfo&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/xml_tests/comments_on_block_command_lines.pl?cvsroot=texinfo&r1=1.8&r2=1.9
Patches:
Index: TODO
===================================================================
RCS file: /sources/texinfo/texinfo/tp/TODO,v
retrieving revision 1.204
retrieving revision 1.205
diff -u -b -r1.204 -r1.205
--- TODO 2 Nov 2011 20:46:37 -0000 1.204
+++ TODO 2 Nov 2011 23:08:17 -0000 1.205
@@ -26,6 +26,28 @@
leads to Second node being node-Next for First node in tp (and not in
texi2html). ---> not sure about this one
+Texinfo::Convert::Text
address@hidden in menu lines (and maybe at other places) should be replaced by
+\n and not eat the end of line.
+
+sectioning/next_in_menu_is_below there should certainly be a warning for
+the subsection that is both below and next the section, because it is
+next in menu.
+
+tests/indices/index_entry_in_footnote_separated_info the node of index
+entry is Top, it should be the node created especially for the footnote
+and the lines count should also be adjusted.
+
+Missing warnings in
+t/19def.t empty_def_arguments
+for
address@hidden {} {}
address@hidden {}
+
+t/30sectioning.t setfilename_on_top_and_after_node
+there could be a warning
+ warning: @setfilename after the first element
+
The result of
@abbr{AAA}. And text.
is not right, space should be doubled after @abbr{AAA}, test in
@@ -40,10 +62,6 @@
to really revert everything, including things that are not set by set_conf.
(There is a FIXME in the code).
-Texinfo::Convert::Text
address@hidden in menu lines (and maybe at other places) should be replaced by
-\n and not eat the end of line.
-
Punctuation and spaces before @image do not lead to a doubling of space.
Following should be an error:
@@ -51,33 +69,15 @@
@heading A heading
@end example
-sectioning/next_in_menu_is_below there should certainly be a warning for
-the subsection that is both below and next the section, because it is
-next in menu.
-
-tests/indices/index_entry_in_footnote_separated_info the node of index
-entry is Top, it should be the node created especially for the footnote
-and the lines count should also be adjusted.
-
Image on sectioning command line haven't their length ignored correctly.
Not sure it is a big deal. An example in sectioning/at_commands_in_refs.
-Missing warnings in
-t/19def.t empty_def_arguments
-for
address@hidden {} {}
address@hidden {}
-
warn when a @noindent/@indent appears within a paragraph.
in info_tests/error_in_footnote there is an error message for each
listoffloats; Line numbers are right, though, so maybe this is not
an issue.
-t/30sectioning.t setfilename_on_top_and_after_node
-there could be a warning
- warning: @setfilename after the first element
-
Missing tests
=============
Index: texi2any.pl
===================================================================
RCS file: /sources/texinfo/texinfo/tp/texi2any.pl,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -b -r1.81 -r1.82
--- texi2any.pl 2 Nov 2011 00:42:13 -0000 1.81
+++ texi2any.pl 2 Nov 2011 23:08:17 -0000 1.82
@@ -716,6 +716,8 @@
$parser_default_options->{'values'}->{'texi2html'} = 1;
} elsif ($var eq 'DEBUGTREE') {
$format = 'debugtree';
+ } elsif ($var eq 'RAW_TEXT') {
+ $format = 'raw_text';
} else {
set_from_cmdline ($var, $value);
# this is very wrong, but a way to avoid a spurious warning.
@@ -835,6 +837,9 @@
'split' => 1,
'converter' => sub{DebugTexinfo::DebugTree->converter(@_)},
},
+ 'raw_text' => {
+ 'converter' => sub{Texinfo::Convert::Text->converter(@_)},
+ },
);
if (!$format_from_command_line and defined($ENV{'TEXINFO_OUTPUT_FORMAT'})
Index: Texinfo/Convert/Text.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Text.pm,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -b -r1.76 -r1.77
--- Texinfo/Convert/Text.pm 1 Nov 2011 16:08:20 -0000 1.76
+++ Texinfo/Convert/Text.pm 2 Nov 2011 23:08:17 -0000 1.77
@@ -291,18 +291,35 @@
return $code_options;
}
-sub convert($;$);
-
sub convert($;$)
{
my $root = shift;
+ # means it was called object oriented
+ if (ref ($root) ne 'HASH') {
+ $root = shift;
+ }
+ my $options = shift;
+ #print STDERR "CONVERT\n";
+ return _convert($root, $options);
+}
+
+sub _convert($;$);
+
+sub _convert($;$)
+{
+ my $root = shift;
my $options = shift;
if (0) {
- print STDERR "root\n";
- print STDERR " Command: $root->{'cmdname'}\n" if ($root->{'cmdname'});
- print STDERR " Type: $root->{'type'}\n" if ($root->{'type'});
- print STDERR " Text: $root->{'text'}\n" if (defined($root->{'text'}));
+ print STDERR "root $root";
+ print STDERR " cmd: address@hidden>{'cmdname'}," if ($root->{'cmdname'});
+ print STDERR " type: $root->{'type'}," if ($root->{'type'});
+ my $text = $root->{'text'};
+ if (defined($text)) {
+ $text =~ s/\n/\\n/;
+ print STDERR " text: `$text'";
+ }
+ print STDERR "\n";
#print STDERR " Special def_command: $root->{'extra'}->{'def_command'}\n"
# if (defined($root->{'extra'}) and $root->{'extra'}->{'def_command'});
}
@@ -343,7 +360,7 @@
and $sort_brace_no_arg_commands{$root->{'cmdname'}}) {
return $sort_brace_no_arg_commands{$root->{'cmdname'}};
} elsif ($options->{'converter'}) {
- return convert(Texinfo::Common::expand_today($options->{'converter'}),
+ return _convert(Texinfo::Common::expand_today($options->{'converter'}),
$options);
} elsif ($options->{'TEST'}) {
return 'a sunny day';
@@ -361,23 +378,23 @@
$options->{'sc'});
return $result;
} elsif ($root->{'cmdname'} eq 'image') {
- return convert($root->{'args'}->[0], _code_options($options));
+ return _convert($root->{'args'}->[0], _code_options($options));
} elsif ($root->{'cmdname'} eq 'email') {
- my $mail = convert($root->{'args'}->[0], _code_options($options));
+ my $mail = _convert($root->{'args'}->[0], _code_options($options));
my $text;
- $text = convert($root->{'args'}->[1], $options)
+ $text = _convert($root->{'args'}->[1], $options)
if (defined($root->{'args'}->[1]));
return $text if (defined($text) and ($text ne ''));
return $mail;
} elsif ($root->{'cmdname'} eq 'uref' or $root->{'cmdname'} eq 'url') {
my $replacement;
- $replacement = convert($root->{'args'}->[2], $options)
+ $replacement = _convert($root->{'args'}->[2], $options)
if (defined($root->{'args'}->[2]));
return $replacement if (defined($replacement) and $replacement ne '');
my $text;
- $text = convert($root->{'args'}->[1], $options)
+ $text = _convert($root->{'args'}->[1], $options)
if (defined($root->{'args'}->[1]));
- my $url = convert($root->{'args'}->[0], _code_options($options));
+ my $url = _convert($root->{'args'}->[0], _code_options($options));
if (defined($text) and $text ne '') {
return "$url ($text)";
} else {
@@ -385,11 +402,11 @@
}
} elsif ($Texinfo::Common::explained_commands{$root->{'cmdname'}}
and $root->{'args'} and $root->{'args'}->[1]) {
- my $explanation = convert($root->{'args'}->[1], $options);
+ my $explanation = _convert($root->{'args'}->[1], $options);
if ($explanation ne '') {
- return convert($root->{'args'}->[0], $options) ." ($explanation)";
+ return _convert($root->{'args'}->[0], $options) ." ($explanation)";
} else {
- return convert($root->{'args'}->[0], $options);
+ return _convert($root->{'args'}->[0], $options);
}
} elsif ($root->{'args'} and $root->{'args'}->[0]
and (($root->{'args'}->[0]->{'type'}
@@ -402,7 +419,7 @@
or $root->{'cmdname'} eq 'math') {
$options = _code_options($options);
}
- $result = convert($root->{'args'}->[0], $options);
+ $result = _convert($root->{'args'}->[0], $options);
return $result;
# block commands
} elsif ($root->{'cmdname'} eq 'quotation'
@@ -410,14 +427,14 @@
or $root->{'cmdname'} eq 'float') {
if ($root->{'args'}) {
foreach my $arg (@{$root->{'args'}}) {
- my $converted_arg = convert($arg, $options);
+ my $converted_arg = _convert($arg, $options);
if ($converted_arg =~ /\S/) {
$result .= $converted_arg.", ";
}
}
$result =~ s/, $//;
chomp ($result);
- $result .= "\n";
+ $result .= "\n" if ($result =~ /\S/);
}
} elsif ($formatting_misc_commands{$root->{'cmdname'}} and
$root->{'args'}) {
if ($root->{'cmdname'} eq 'sp') {
@@ -432,10 +449,10 @@
= Texinfo::Common::expand_verbatiminclude($options->{'converter'},
$root);
if (defined($verbatim_include_verbatim)) {
- $result .= convert($verbatim_include_verbatim, $options);
+ $result .= _convert($verbatim_include_verbatim, $options);
}
} elsif ($root->{'cmdname'} ne 'node') {
- $result = convert($root->{'args'}->[0], $options);
+ $result = _convert($root->{'args'}->[0], $options);
if ($Texinfo::Common::sectioning_commands{$root->{'cmdname'}}) {
$result = heading ($root, $result, $options->{'converter'},
$options->{'NUMBER_SECTIONS'});
@@ -472,15 +489,15 @@
push @contents, @$arguments;
}
push @contents, {'text' => "\n"};
- $result = convert({'contents' => address@hidden,
_code_options($options));
+ $result = _convert({'contents' => address@hidden,
_code_options($options));
}
#$result = convert($root->{'args'}->[0], $options) if ($root->{'args'});
} elsif ($root->{'type'} and $root->{'type'} eq 'menu_entry') {
foreach my $arg (@{$root->{'args'}}) {
if ($arg->{'type'} eq 'menu_entry_node') {
- $result .= convert($arg, _code_options($options));
+ $result .= _convert($arg, _code_options($options));
} else {
- $result .= convert($arg, $options);
+ $result .= _convert($arg, $options);
}
}
}
@@ -493,7 +510,7 @@
cluck "contents not an array($root->{'contents'}).";
}
foreach my $content (@{$root->{'contents'}}) {
- $result .= convert($content, $options);
+ $result .= _convert($content, $options);
}
}
$result = '{'.$result.'}'
@@ -501,9 +518,113 @@
and (!$root->{'parent'}->{'type'} or
($root->{'parent'}->{'type'} ne 'block_line_arg'
and $root->{'parent'}->{'type'} ne 'misc_line_arg')));
+ #print STDERR " RR ($root) -> $result\n";
+ return $result;
+}
+
+
+
+# Implement the converters API, but as simply as possible
+# initialization
+sub converter($)
+{
+ my $class = shift;
+ my $conf;
+ my $converter = {};
+ if (ref($class) eq 'HASH') {
+ $conf = $class;
+ bless $converter;
+ } elsif (defined($class)) {
+ bless $converter, $class;
+ $conf = shift;
+ } else {
+ bless $converter;
+ $conf = shift;
+ }
+
+ if ($conf) {
+ %{$converter} = %{$conf};
+ }
+ bless $converter;
+ return $converter;
+}
+
+sub convert_tree($$)
+{
+ my $self = shift;
+ my $root = shift;
+
+ return _convert($root);
+}
+
+# determine outfile and output to that file
+my $STDIN_DOCU_NAME = 'stdin';
+sub output($$)
+{
+ my $self = shift;
+ my $tree = shift;
+ #print STDERR "OUTPUT\n";
+ if ($self and $self->{'parser'}) {
+ my $parser = $self->{'parser'};
+ $self->{'info'} = $self->{'parser'}->global_informations();
+ $self->{'extra'} = $self->{'parser'}->global_commands_information();
+ }
+ my $input_basename;
+ if (defined($self->{'info'}->{'input_file_name'})) {
+ $input_basename = $self->{'info'}->{'input_file_name'};
+ } else {
+ # This could happen if called on a piece of texinfo
+ $input_basename = '';
+ }
+ $input_basename =~ s/^.*\///;
+ $self->{'input_basename'} = $input_basename;
+ $input_basename = $STDIN_DOCU_NAME if ($input_basename eq '-');
+ $input_basename =~ s/\.te?x(i|info)?$//;
+
+ my $setfilename;
+ $setfilename = $self->{'extra'}->{'setfilename'}->{'extra'}->{'text_arg'}
+ if ($self->{'extra'} and $self->{'extra'}->{'setfilename'}
+ and $self->{'extra'}->{'setfilename'}->{'extra'}
+ and
defined($self->{'extra'}->{'setfilename'}->{'extra'}->{'text_arg'}));
+ if (!defined($self->{'OUTFILE'})) {
+ my $outfile;
+ if (defined($setfilename)) {
+ $outfile = $setfilename;
+ $outfile =~ s/\.[^\.]*$//;
+ } elsif ($input_basename ne '') {
+ $outfile = $input_basename;
+ }
+ if (defined($outfile)) {
+ $outfile .= '.txt';
+ $self->{'OUTFILE'} = $outfile;
+ }
+ }
+ my $fh;
+ if (defined($self->{'OUTFILE'})) {
+ $fh = $self->Texinfo::Common::open_out ($self->{'OUTFILE'});
+ return undef if (!$fh);
+ }
+ my $result = _convert($tree);
+ if ($fh) {
+ print $fh $result;
+ $result = '';
+ }
return $result;
}
+sub get_conf($$)
+{
+ my $self = shift;
+ my $key = shift;
+
+ return $self->{$key};
+}
+
+sub errors()
+{
+ return undef;
+}
+
1;
__END__
Index: t/results/quotation/empty_quotation.pl
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/results/quotation/empty_quotation.pl,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- t/results/quotation/empty_quotation.pl 18 Sep 2011 20:34:38 -0000
1.7
+++ t/results/quotation/empty_quotation.pl 2 Nov 2011 23:08:17 -0000
1.8
@@ -435,8 +435,6 @@
Empty
-
-
';
$result_errors{'empty_quotation'} = [];
Index: t/results/quotation/only_comment_on_quotation_line.pl
===================================================================
RCS file:
/sources/texinfo/texinfo/tp/t/results/quotation/only_comment_on_quotation_line.pl,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- t/results/quotation/only_comment_on_quotation_line.pl 18 Sep 2011
20:34:38 -0000 1.4
+++ t/results/quotation/only_comment_on_quotation_line.pl 2 Nov 2011
23:08:18 -0000 1.5
@@ -126,8 +126,7 @@
';
-$result_texts{'only_comment_on_quotation_line'} = '
-In quotation
+$result_texts{'only_comment_on_quotation_line'} = 'In quotation
';
$result_errors{'only_comment_on_quotation_line'} = [];
Index: t/results/xml_tests/comments_on_block_command_lines.pl
===================================================================
RCS file:
/sources/texinfo/texinfo/tp/t/results/xml_tests/comments_on_block_command_lines.pl,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- t/results/xml_tests/comments_on_block_command_lines.pl 17 Sep 2011
21:24:00 -0000 1.8
+++ t/results/xml_tests/comments_on_block_command_lines.pl 2 Nov 2011
23:08:18 -0000 1.9
@@ -2399,7 +2399,6 @@
it
-
Quot no arg
quotarg
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- texinfo/tp TODO texi2any.pl Texinfo/Convert/Tex...,
Patrice Dumas <=