[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
texinfo/tp texi2any.pl Texinfo/Common.pm Texinf...
From: |
Patrice Dumas |
Subject: |
texinfo/tp texi2any.pl Texinfo/Common.pm Texinf... |
Date: |
Sun, 30 Oct 2011 10:13:20 +0000 |
CVSROOT: /sources/texinfo
Module name: texinfo
Changes by: Patrice Dumas <pertusus> 11/10/30 10:13:20
Modified files:
tp : texi2any.pl
tp/Texinfo : Common.pm Structuring.pm
tp/Texinfo/Convert: Converter.pm DocBook.pm HTML.pm Info.pm
Plaintext.pm XML.pm
tp/init : chm.pm
tp/maintain : template.pod
Log message:
Put output_internal_links in the converters and make it return text.
open_out: take the encoding information from the first argument if
there is no encoding in argument.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/texi2any.pl?cvsroot=texinfo&r1=1.78&r2=1.79
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Common.pm?cvsroot=texinfo&r1=1.85&r2=1.86
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Structuring.pm?cvsroot=texinfo&r1=1.99&r2=1.100
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Converter.pm?cvsroot=texinfo&r1=1.56&r2=1.57
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/DocBook.pm?cvsroot=texinfo&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/HTML.pm?cvsroot=texinfo&r1=1.193&r2=1.194
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Info.pm?cvsroot=texinfo&r1=1.67&r2=1.68
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Plaintext.pm?cvsroot=texinfo&r1=1.177&r2=1.178
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/XML.pm?cvsroot=texinfo&r1=1.47&r2=1.48
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/init/chm.pm?cvsroot=texinfo&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/maintain/template.pod?cvsroot=texinfo&r1=1.1&r2=1.2
Patches:
Index: texi2any.pl
===================================================================
RCS file: /sources/texinfo/texinfo/tp/texi2any.pl,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -b -r1.78 -r1.79
--- texi2any.pl 29 Oct 2011 11:31:55 -0000 1.78
+++ texi2any.pl 30 Oct 2011 10:13:19 -0000 1.79
@@ -941,8 +941,8 @@
my $texinfo_text = Texinfo::Convert::Texinfo::convert ($tree);
#print STDERR "$texinfo_text\n";
my $macro_expand_file = get_conf('MACRO_EXPAND');
- my $macro_expand_fh = Texinfo::Common::open_out({}, $macro_expand_file,
- $parser->{'perl_encoding'});
+ my $macro_expand_fh = Texinfo::Common::open_out($parser,
+ $macro_expand_file);
if (defined ($macro_expand_fh)) {
print $macro_expand_fh $texinfo_text;
close ($macro_expand_fh);
@@ -994,13 +994,16 @@
handle_errors($converter, $error_count);
if (defined(get_conf('INTERNAL_LINKS')) and $file_number == 0
and $formats_table{$format}->{'internal_links'}) {
+ my $internal_links_text
+ = $converter->output_internal_links();
+ # FIXME output only if there are links or always, maybe creating an
+ # empty file.
+ if (defined($internal_links_text)) {
my $internal_links_file = get_conf('INTERNAL_LINKS');
- my $internal_links_fh = Texinfo::Common::open_out({}, $internal_links_file,
- $parser->{'perl_encoding'});
+ my $internal_links_fh = Texinfo::Common::open_out($converter,
+ $internal_links_file);
if (defined ($internal_links_fh)) {
- # FIXME no possibility of configuration?
- Texinfo::Structuring::output_internal_links($converter,
- $internal_links_fh);
+ print $internal_links_fh $internal_links_text;
close ($internal_links_fh);
} else {
warn (sprintf(__("Could not open %s for writing: %s\n"),
@@ -1010,5 +1013,6 @@
or $error_count > get_conf('ERROR_LIMIT')));
}
}
+ }
}
Index: Texinfo/Common.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Common.pm,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -b -r1.85 -r1.86
--- Texinfo/Common.pm 30 Oct 2011 00:51:17 -0000 1.85
+++ Texinfo/Common.pm 30 Oct 2011 10:13:19 -0000 1.86
@@ -749,15 +749,20 @@
my $self = shift;
my $file = shift;
my $encoding = shift;
+
+ if (!defined($encoding) and $self and defined($self->{'perl_encoding'})) {
+ $encoding = $self->{'perl_encoding'};
+ }
+
if ($file eq '-') {
- binmode(STDOUT, ":encoding($encoding)") if (defined($encoding));
+ binmode(STDOUT, ":encoding($encoding)") if ($encoding);
return \*STDOUT;
}
my $filehandle = do { local *FH };
if (!open ($filehandle, '>', $file)) {
return undef;
}
- if (defined($encoding)) {
+ if ($encoding) {
if ($encoding eq 'utf8' or $encoding eq 'utf-8-strict') {
binmode($filehandle, ':utf8');
} else { # FIXME also right for shiftijs or similar encodings?
@@ -765,7 +770,8 @@
}
binmode($filehandle, ":encoding($encoding)");
}
- push @{$self->{'opened_files'}}, $file;
+ push @{$self->{'opened_files'}}, $file
+ if ($self);
return $filehandle;
}
Index: Texinfo/Structuring.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Structuring.pm,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -b -r1.99 -r1.100
--- Texinfo/Structuring.pm 16 Oct 2011 22:33:57 -0000 1.99
+++ Texinfo/Structuring.pm 30 Oct 2011 10:13:19 -0000 1.100
@@ -21,9 +21,6 @@
package Texinfo::Structuring;
-# FIXME output_internal_links is not documented, but it is not clear
-# that is belongs here
-
use 5.00405;
use strict;
@@ -51,7 +48,6 @@
nodes_tree
number_floats
menu_to_simple_menu
- output_internal_links
sectioning_structure
set_menus_to_simple_menu
sort_indices
@@ -1199,56 +1195,6 @@
return $merged_index_entries;
}
-sub output_internal_links($$$)
-{
- my $self = shift;
- my $fh = shift;
- if ($self->{'elements'}) {
- foreach my $element (@{$self->{'elements'}}) {
- my $text;
- my $href;
- my $command = $self->element_command($element);
- if (defined($command)) {
- # Use '' for filename, to force a filename in href.
- $href = $self->command_href($command, '');
- my $tree = $self->command_text($command, 'tree');
- if ($tree) {
- $text = Texinfo::Convert::Text::convert($tree,
- {Texinfo::Common::_convert_text_options($self)});
- }
- }
- if (defined($href) or defined($text)) {
- my $out_string = '';
- $out_string .= $href if (defined($href));
- $out_string .= "\ttoc\t";
- $out_string .= $text if (defined($text));
- $out_string .= "\n";
- print $fh $out_string;
- }
- }
- }
- if ($self->{'parser'}) {
- foreach my $index_name (sort(keys
(%{$self->{'index_entries_by_letter'}}))) {
- foreach my $letter_entry
(@{$self->{'index_entries_by_letter'}->{$index_name}}) {
- foreach my $index_entry (@{$letter_entry->{'entries'}}) {
- my $href;
- my $key;
- $href = $self->command_href($index_entry->{'command'}, '');
- $key = $index_entry->{'key'};
- if (defined($key) and $key =~ /\S/) {
- my $out_string = '';
- $out_string .= $href if (defined($href));
- $out_string .= "\t$index_name\t";
- $out_string .= $key;
- $out_string .= "\n";
- print $fh $out_string;
- }
- }
- }
- }
- }
-}
-
# modify the menu tree to put description and menu comment content
# together directly in the menu. Put the menu_entry in a preformatted.
# last merge preformatted.
Index: Texinfo/Convert/Converter.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Converter.pm,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -b -r1.56 -r1.57
--- Texinfo/Convert/Converter.pm 22 Oct 2011 13:15:32 -0000 1.56
+++ Texinfo/Convert/Converter.pm 30 Oct 2011 10:13:19 -0000 1.57
@@ -97,6 +97,11 @@
return ('documentlanguage', 'documentencoding');
}
+sub output_internal_links($)
+{
+ my $self = shift;
+ return undef;
+}
# FIXME documentencoding handling is not reverted by resetting
# a value with set_conf, so _unset_global_multiple_commands won't
Index: Texinfo/Convert/DocBook.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/DocBook.pm,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- Texinfo/Convert/DocBook.pm 10 Oct 2011 00:07:54 -0000 1.23
+++ Texinfo/Convert/DocBook.pm 30 Oct 2011 10:13:19 -0000 1.24
@@ -302,8 +302,7 @@
my $fh;
if (! $self->get_conf('OUTFILE') eq '') {
- $fh = $self->Texinfo::Common::open_out ($self->get_conf('OUTFILE'),
- $self->{'perl_encoding'});
+ $fh = $self->Texinfo::Common::open_out ($self->get_conf('OUTFILE'));
if (!$fh) {
$self->document_error(sprintf($self->__("Could not open %s for writing:
%s"),
$self->get_conf('OUTFILE'), $!));
@@ -1285,6 +1284,12 @@
output. This function do not try to output a full document but only
portions of document. For a full document use C<convert>.
+=item $result = $converter->output_internal_links()
+
+Returns text representing the links in the document. At present the format
+should follow the C<--internal-links> option of texi2any/makeinfo specification
+and this is only relevant for HTML.
+
=back
=head1 AUTHOR
Index: Texinfo/Convert/HTML.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/HTML.pm,v
retrieving revision 1.193
retrieving revision 1.194
diff -u -b -r1.193 -r1.194
--- Texinfo/Convert/HTML.pm 22 Oct 2011 19:56:26 -0000 1.193
+++ Texinfo/Convert/HTML.pm 30 Oct 2011 10:13:20 -0000 1.194
@@ -45,6 +45,7 @@
convert
convert_tree
output
+ output_internal_links
) ] );
@EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
@@ -6125,8 +6126,7 @@
$toc_frame_outfile = $toc_frame_file;
}
- my $frame_fh = $self->Texinfo::Common::open_out ($frame_outfile,
- $self->{'perl_encoding'});
+ my $frame_fh = $self->Texinfo::Common::open_out ($frame_outfile);
if (defined($frame_fh)) {
my $doctype = $self->get_conf('FRAMESET_DOCTYPE');
my $top_file = '';
@@ -6148,8 +6148,7 @@
}
- my $toc_frame_fh = $self->Texinfo::Common::open_out ($toc_frame_outfile,
- $self->{'perl_encoding'});
+ my $toc_frame_fh = $self->Texinfo::Common::open_out ($toc_frame_outfile);
if (defined($toc_frame_fh)) {
my $header = &{$self->{'format_begin_file'}}($self, $toc_frame_file,
undef);
@@ -6189,6 +6188,58 @@
return $result;
}
+# This is called from the main program on the converter.
+sub output_internal_links($)
+{
+ my $self = shift;
+ my $out_string = '';
+ if ($self->{'elements'}) {
+ foreach my $element (@{$self->{'elements'}}) {
+ my $text;
+ my $href;
+ my $command = $self->element_command($element);
+ if (defined($command)) {
+ # Use '' for filename, to force a filename in href.
+ $href = $self->command_href($command, '');
+ my $tree = $self->command_text($command, 'tree');
+ if ($tree) {
+ $text = Texinfo::Convert::Text::convert($tree,
+ {Texinfo::Common::_convert_text_options($self)});
+ }
+ }
+ if (defined($href) or defined($text)) {
+ $out_string .= $href if (defined($href));
+ $out_string .= "\ttoc\t";
+ $out_string .= $text if (defined($text));
+ $out_string .= "\n";
+ }
+ }
+ }
+ if ($self->{'parser'}) {
+ foreach my $index_name (sort(keys
(%{$self->{'index_entries_by_letter'}}))) {
+ foreach my $letter_entry
(@{$self->{'index_entries_by_letter'}->{$index_name}}) {
+ foreach my $index_entry (@{$letter_entry->{'entries'}}) {
+ my $href;
+ my $key;
+ $href = $self->command_href($index_entry->{'command'}, '');
+ $key = $index_entry->{'key'};
+ if (defined($key) and $key =~ /\S/) {
+ $out_string .= $href if (defined($href));
+ $out_string .= "\t$index_name\t";
+ $out_string .= $key;
+ $out_string .= "\n";
+ }
+ }
+ }
+ }
+ }
+ if ($out_string ne '') {
+ return $out_string;
+ } else {
+ return undef;
+ }
+}
+
my @possible_stages = ('setup', 'structure', 'init', 'finish');
my %possible_stages;
foreach my $stage (@possible_stages) {
@@ -6447,8 +6498,7 @@
if ($self->get_conf('OUTFILE') ne '') {
print STDERR "DO No pages, output in ".$self->get_conf('OUTFILE')."\n"
if ($self->get_conf('DEBUG'));
- $fh = $self->Texinfo::Common::open_out ($self->get_conf('OUTFILE'),
- $self->{'perl_encoding'});
+ $fh = $self->Texinfo::Common::open_out ($self->get_conf('OUTFILE'));
if (!$fh) {
$self->document_error(sprintf($self->__("Could not open %s for
writing: %s"),
$self->get_conf('OUTFILE'), $!));
@@ -6497,8 +6547,7 @@
}
# Then open the file and output the elements or the special_page_content
if (!$files{$element->{'filename'}}->{'fh'}) {
- $file_fh = $self->Texinfo::Common::open_out
($element->{'out_filename'},
- $self->{'perl_encoding'});
+ $file_fh = $self->Texinfo::Common::open_out
($element->{'out_filename'});
if (!$file_fh) {
$self->document_error(sprintf($self->__("Could not open %s for
writing: %s"),
$element->{'out_filename'}, $!));
@@ -6563,8 +6612,7 @@
} else {
$out_filename = $node_filename;
}
- my $file_fh = $self->Texinfo::Common::open_out ($out_filename,
- $self->{'perl_encoding'});
+ my $file_fh = $self->Texinfo::Common::open_out ($out_filename);
if (!$file_fh) {
$self->document_error(sprintf($self->__("Could not open %s for
writing: %s"),
$out_filename, $!));
@@ -6618,8 +6666,7 @@
} else {
$out_filename = $filename;
}
- my $file_fh = $self->Texinfo::Common::open_out ($out_filename,
- $self->{'perl_encoding'});
+ my $file_fh = $self->Texinfo::Common::open_out ($out_filename);
if (!$file_fh) {
$self->document_error(sprintf($self->__("Could not open %s for
writing: %s"),
$out_filename, $!));
@@ -7104,6 +7151,12 @@
output. This function do not try to output a full document but only
portions of document. For a full document use C<convert>.
+=item $result = $converter->output_internal_links()
+
+Returns text representing the links in the document. At present the format
+should follow the C<--internal-links> option of texi2any/makeinfo specification
+and this is only relevant for HTML.
+
=back
=head1 AUTHOR
Index: Texinfo/Convert/Info.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Info.pm,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -b -r1.67 -r1.68
--- Texinfo/Convert/Info.pm 1 Oct 2011 22:54:12 -0000 1.67
+++ Texinfo/Convert/Info.pm 30 Oct 2011 10:13:20 -0000 1.68
@@ -77,8 +77,7 @@
my $fh;
if (! $self->get_conf('OUTFILE') eq '') {
- $fh = $self->Texinfo::Common::open_out ($self->get_conf('OUTFILE'),
- $self->{'perl_encoding'});
+ $fh = $self->Texinfo::Common::open_out ($self->get_conf('OUTFILE'));
if (!$fh) {
$self->document_error(sprintf($self->__("Could not open %s for writing:
%s"),
$self->get_conf('OUTFILE'), $!));
@@ -139,8 +138,7 @@
}
$out_file_nr++;
$fh = $self->Texinfo::Common::open_out (
- $self->get_conf('OUTFILE').'-'.$out_file_nr,
- $self->{'perl_encoding'});
+ $self->get_conf('OUTFILE').'-'.$out_file_nr);
if (!$fh) {
$self->document_error(sprintf(
$self->__("Could not open %s for writing: %s"),
@@ -158,8 +156,7 @@
my $tag_text = '';
if ($out_file_nr > 1) {
close ($fh);
- $fh = $self->Texinfo::Common::open_out($self->get_conf('OUTFILE'),
- $self->{'perl_encoding'});
+ $fh = $self->Texinfo::Common::open_out($self->get_conf('OUTFILE'));
if (!$fh) {
$self->document_error(sprintf(
$self->__("Could not open %s for writing: %s"),
@@ -644,6 +641,12 @@
output. This function do not try to output a full document but only
portions of document. For a full document use C<convert>.
+=item $result = $converter->output_internal_links()
+
+Returns text representing the links in the document. At present the format
+should follow the C<--internal-links> option of texi2any/makeinfo specification
+and this is only relevant for HTML.
+
=back
=head1 AUTHOR
Index: Texinfo/Convert/Plaintext.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Plaintext.pm,v
retrieving revision 1.177
retrieving revision 1.178
diff -u -b -r1.177 -r1.178
--- Texinfo/Convert/Plaintext.pm 29 Oct 2011 11:31:56 -0000 1.177
+++ Texinfo/Convert/Plaintext.pm 30 Oct 2011 10:13:20 -0000 1.178
@@ -409,8 +409,7 @@
$outfile = $self->get_conf('OUTFILE');
}
- my $fh = $self->Texinfo::Common::open_out ($outfile,
- $self->{'perl_encoding'});
+ my $fh = $self->Texinfo::Common::open_out ($outfile);
if (!$fh) {
$self->document_error(sprintf($self->__("Could not open %s for writing:
%s"),
$outfile, $!));
@@ -2504,6 +2503,12 @@
output. This function do not try to output a full document but only
portions of document. For a full document use C<convert>.
+=item $result = $converter->output_internal_links()
+
+Returns text representing the links in the document. At present the format
+should follow the C<--internal-links> option of texi2any/makeinfo specification
+and this is only relevant for HTML.
+
=back
=head1 AUTHOR
Index: Texinfo/Convert/XML.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/XML.pm,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -b -r1.47 -r1.48
--- Texinfo/Convert/XML.pm 19 Oct 2011 21:21:41 -0000 1.47
+++ Texinfo/Convert/XML.pm 30 Oct 2011 10:13:20 -0000 1.48
@@ -260,8 +260,7 @@
my $fh;
if (! $self->get_conf('OUTFILE') eq '') {
- $fh = $self->Texinfo::Common::open_out ($self->get_conf('OUTFILE'),
- $self->{'perl_encoding'});
+ $fh = $self->Texinfo::Common::open_out ($self->get_conf('OUTFILE'));
if (!$fh) {
$self->document_error(sprintf($self->__("Could not open %s for writing:
%s"),
$self->get_conf('OUTFILE'), $!));
@@ -1029,6 +1028,12 @@
output. This function do not try to output a full document but only
portions of document. For a full document use C<convert>.
+=item $result = $converter->output_internal_links()
+
+Returns text representing the links in the document. At present the format
+should follow the C<--internal-links> option of texi2any/makeinfo specification
+and this is only relevant for HTML.
+
=back
=head1 AUTHOR
Index: init/chm.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/init/chm.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- init/chm.pm 18 Oct 2011 18:47:22 -0000 1.5
+++ init/chm.pm 30 Oct 2011 10:13:20 -0000 1.6
@@ -211,8 +211,7 @@
my $hhk_filename = $document_name . ".hhk";
my $hhk_file = $self->{'destination_directory'} . $hhk_filename;
- my $hhk_fh = Texinfo::Common::open_out($self, $hhk_file,
- $self->{'perl_encoding'});
+ my $hhk_fh = Texinfo::Common::open_out($self, $hhk_file);
# Not sure $! is still valid
if (!defined($hhk_fh)) {
die sprintf($self->__("Can't open %s for writing: %s\n"),
@@ -232,8 +231,7 @@
my $hhp_filename = $document_name . ".hhp";
my $hhp_file = $self->{'destination_directory'} . $hhp_filename;
- my $hhp_fh = Texinfo::Common::open_out($self, $hhp_file,
- $self->{'perl_encoding'});
+ my $hhp_fh = Texinfo::Common::open_out($self, $hhp_file);
# Not sure $! is still valid
if (!defined($hhp_fh)) {
die sprintf($self->__("Can't open %s for writing: %s\n"),
@@ -287,8 +285,7 @@
my $hhc_filename = $document_name . ".hhc";
my $hhc_file = $self->{'destination_directory'} . $hhc_filename;
- my $hhc_fh = Texinfo::Common::open_out($self, $hhc_file,
- $self->{'perl_encoding'});
+ my $hhc_fh = Texinfo::Common::open_out($self, $hhc_file);
# Not sure $! is still valid
if (!defined($hhc_fh)) {
die sprintf($self->__("Can't open %s for writing: %s\n"),
Index: maintain/template.pod
===================================================================
RCS file: /sources/texinfo/texinfo/tp/maintain/template.pod,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- maintain/template.pod 1 Oct 2011 22:54:12 -0000 1.1
+++ maintain/template.pod 30 Oct 2011 10:13:20 -0000 1.2
@@ -47,6 +47,12 @@
output. This function do not try to output a full document but only
portions of document. For a full document use C<convert>.
+=item $result = $converter->output_internal_links()
+
+Returns text representing the links in the document. At present the format
+should follow the C<--internal-links> option of texi2any/makeinfo specification
+and this is only relevant for HTML.
+
=back
=head1 AUTHOR
- texinfo/tp texi2any.pl Texinfo/Common.pm Texinf..., Patrice Dumas, 2011/10/02
- texinfo/tp texi2any.pl Texinfo/Common.pm Texinf..., Patrice Dumas, 2011/10/08
- texinfo/tp texi2any.pl Texinfo/Common.pm Texinf..., Patrice Dumas, 2011/10/10
- texinfo/tp texi2any.pl Texinfo/Common.pm Texinf..., Patrice Dumas, 2011/10/11
- texinfo/tp texi2any.pl Texinfo/Common.pm Texinf..., Patrice Dumas, 2011/10/21
- texinfo/tp texi2any.pl Texinfo/Common.pm Texinf..., Patrice Dumas, 2011/10/29
- texinfo/tp texi2any.pl Texinfo/Common.pm Texinf...,
Patrice Dumas <=