[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
texinfo/tp Makefile.am TODO texi2any.pl Texinfo...
From: |
Patrice Dumas |
Subject: |
texinfo/tp Makefile.am TODO texi2any.pl Texinfo... |
Date: |
Mon, 10 Oct 2011 00:07:55 +0000 |
CVSROOT: /sources/texinfo
Module name: texinfo
Changes by: Patrice Dumas <pertusus> 11/10/10 00:07:55
Modified files:
tp : Makefile.am TODO texi2any.pl
tp/Texinfo/Convert: DocBook.pm HTML.pm Unicode.pm
tp/init : book.pm
Added files:
tp/init : chm.pm
Log message:
Add chm.pm.
Allow using handlers.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Makefile.am?cvsroot=texinfo&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/TODO?cvsroot=texinfo&r1=1.188&r2=1.189
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/texi2any.pl?cvsroot=texinfo&r1=1.67&r2=1.68
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/DocBook.pm?cvsroot=texinfo&r1=1.22&r2=1.23
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/HTML.pm?cvsroot=texinfo&r1=1.177&r2=1.178
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Unicode.pm?cvsroot=texinfo&r1=1.21&r2=1.22
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/init/book.pm?cvsroot=texinfo&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/init/chm.pm?cvsroot=texinfo&rev=1.1
Patches:
Index: Makefile.am
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Makefile.am,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- Makefile.am 8 Oct 2011 20:04:45 -0000 1.7
+++ Makefile.am 10 Oct 2011 00:07:54 -0000 1.8
@@ -58,7 +58,10 @@
DebugTexinfo/DebugTree.pm
initdir = $(datadir)/texinfo/init
-dist_init_DATA = init/html32.pm
+dist_init_DATA = \
+ init/book.pm \
+ init/chm.pm \
+ init/html32.pm
test_files = \
t/27float.t \
Index: TODO
===================================================================
RCS file: /sources/texinfo/texinfo/tp/TODO,v
retrieving revision 1.188
retrieving revision 1.189
diff -u -b -r1.188 -r1.189
--- TODO 7 Oct 2011 23:53:23 -0000 1.188
+++ TODO 10 Oct 2011 00:07:54 -0000 1.189
@@ -250,7 +250,11 @@
Add @value to the corresponding commands categories?
-Functions:
+Instead of _set_global_multiple_commands and _unset_global_multiple_commands
+have a better granularity and do something per command, with the possibility
+to really revert everything, including things that are not set by set_conf.
+
+Functions (?):
sectioning_command_target_name
node_target_name
Index: texi2any.pl
===================================================================
RCS file: /sources/texinfo/texinfo/tp/texi2any.pl,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -b -r1.67 -r1.68
--- texi2any.pl 8 Oct 2011 09:59:18 -0000 1.67
+++ texi2any.pl 10 Oct 2011 00:07:54 -0000 1.68
@@ -375,10 +375,11 @@
my $format_from_command_line = 0;
sub set_format($)
{
- my $format = shift;
- $default_expanded_format = [$format];
+ my $set_format = shift;
+ $default_expanded_format = [$set_format];
$format_from_command_line = 1;
- return $format;
+ $format = $set_format;
+ return $set_format;
}
my $call_texi2dvi = 0;
Index: Texinfo/Convert/DocBook.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/DocBook.pm,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- Texinfo/Convert/DocBook.pm 1 Oct 2011 22:54:12 -0000 1.22
+++ Texinfo/Convert/DocBook.pm 10 Oct 2011 00:07:54 -0000 1.23
@@ -92,17 +92,16 @@
"\t" => $nbsp,
"\n" => $nbsp,
" " => $nbsp,
+ 'tie' => $nbsp,
# FIXME and '*'?
);
my %docbook_commands_formatting
= %{$Texinfo::Convert::Converter::default_xml_commands_formatting{'normal'}};
-foreach my $command (keys(%Texinfo::Convert::Unicode::unicode_map)) {
+foreach my $command (keys(%Texinfo::Convert::Unicode::unicode_entities)) {
$docbook_commands_formatting{$command}
- = '&#'.hex($Texinfo::Convert::Unicode::unicode_map{$command}).';'
- if ($Texinfo::Convert::Unicode::unicode_map{$command} ne '');
+ = $Texinfo::Convert::Unicode::unicode_entities{$command};
}
-$docbook_commands_formatting{'tie'} = $nbsp;
foreach my $command (keys(%docbook_specific_formatting)) {
$docbook_commands_formatting{$command}
Index: Texinfo/Convert/HTML.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/HTML.pm,v
retrieving revision 1.177
retrieving revision 1.178
diff -u -b -r1.177 -r1.178
--- Texinfo/Convert/HTML.pm 9 Oct 2011 00:49:37 -0000 1.177
+++ Texinfo/Convert/HTML.pm 10 Oct 2011 00:07:54 -0000 1.178
@@ -4840,6 +4840,13 @@
my $top_node_filename;
if (defined($self->get_conf('TOP_NODE_FILE'))) {
$top_node_filename = $self->get_conf('TOP_NODE_FILE');
+ } else {
+ # FIXME this is like texi2html, but is it right? Shouldn't it
+ # better to leave it undefined? In that case the section name
+ # may be used, or the node name, or something along document_name-0
+ $top_node_filename = $self->{'document_name'};
+ }
+ if (defined($top_node_filename)) {
$top_node_filename .= '.'.$self->get_conf('NODE_FILE_EXTENSION')
if (defined($self->get_conf('NODE_FILE_EXTENSION'))
and $self->get_conf('NODE_FILE_EXTENSION') ne '');
@@ -4849,9 +4856,9 @@
and defined($top_node_filename)) {
my ($node_top_element) = $self->_get_element($node_top);
die "BUG: No page for top node" if (!defined($node_top));
- if (defined($self->get_conf('TOP_NODE_FILE'))) {
+ #if (defined($self->get_conf('TOP_NODE_FILE'))) {
$self->_set_element_file($node_top_element, $top_node_filename);
- }
+ #}
}
# FIXME add a number for each page?
my $file_nr = 0;
@@ -5220,6 +5227,7 @@
$self->{'index_entries_by_letter'}
=
$self->Texinfo::Structuring::sort_indices_by_letter($merged_index_entries,
$index_names);
+ $self->{'index_entries'} = $merged_index_entries;
foreach my $index_name (sort(keys(%$index_entries))) {
foreach my $index_entry (@{$index_entries->{$index_name}}) {
@@ -6005,6 +6013,55 @@
return $result;
}
+my @possible_stages = ('setup', 'structure', 'init', 'finish');
+my %possible_stages;
+foreach my $stage (@possible_stages) {
+ $possible_stages{$stage} = 1;
+}
+
+sub run_stage_handlers($$)
+{
+ my $converter = shift;
+ my $stage = shift;
+ die if (!$possible_stages{$stage});
+
+ return if
(!defined($Texinfo::Config::texinfo_default_stage_handlers{$stage}));
+
+ my @sorted_priorities = sort
keys(%{$Texinfo::Config::texinfo_default_stage_handlers{$stage}});
+ foreach my $priority (@sorted_priorities) {
+ foreach my $handler
(@{$Texinfo::Config::texinfo_default_stage_handlers{$stage}->{$priority}}) {
+ if ($converter->get_conf('DEBUG')) {
+ print STDERR "HANDLER($stage) , priority $priority: $handler\n";
+ }
+ &{$handler}($converter);
+ }
+ }
+}
+
+my $default_priority = 'default';
+
+{
+package Texinfo::Config;
+
+use vars qw(%texinfo_default_stage_handlers);
+
+sub texinfo_register_handler($$;$)
+{
+ my $stage = shift;
+ my $handler = shift;
+ my $priority = shift;
+
+ if (!$possible_stages{$stage}) {
+ carp ("Unknown stage $stage\n");
+ return 0;
+ }
+ $priority = $default_priority if (!defined($priority));
+ push @{$texinfo_default_stage_handlers{$stage}->{$priority}}, $handler;
+ return 1;
+}
+
+}
+
sub output($$)
{
my $self = shift;
@@ -6027,6 +6084,8 @@
}
$self->set_conf('EXTERNAL_CROSSREF_SPLIT', $self->get_conf('SPLIT'));
+ $self->run_stage_handlers('setup');
+
$self->_prepare_css();
# this sets OUTFILE, to be used if not split, but also
@@ -6079,6 +6138,8 @@
$self->_prepare_index_entries();
$self->_prepare_footnotes();
+ $self->run_stage_handlers('structure');
+
$self->set_conf('BODYTEXT', 'lang="' . $self->get_conf('documentlanguage')
. '" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080"
alink="#FF0000"');
@@ -6162,6 +6223,9 @@
chomp($self->{'documentdescription_string'});
pop @{$self->{'document_context'}};
}
+
+ $self->run_stage_handlers('init');
+
# Now do the output
my $fh;
my $output = '';
@@ -6248,6 +6312,9 @@
}
}
}
+
+ $self->run_stage_handlers('finish');
+
$self->{'current_filename'} = undef;
if ($self->get_conf('NODE_FILES')
and $self->{'labels'} and $self->get_conf('OUTFILE') ne '') {
@@ -6258,6 +6325,7 @@
# @titlepage, and @titlepage is not used.
my $filename = $self->command_filename($node);
my $node_filename;
+ # FIXME texi2html always use 'node_filename' even for Top.
if ($node->{'extra'}->{'normalized'} eq 'Top'
and defined($self->get_conf('TOP_NODE_FILE_TARGET'))) {
my $extension = '';
Index: Texinfo/Convert/Unicode.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Unicode.pm,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- Texinfo/Convert/Unicode.pm 30 Sep 2011 22:31:31 -0000 1.21
+++ Texinfo/Convert/Unicode.pm 10 Oct 2011 00:07:54 -0000 1.22
@@ -544,6 +544,15 @@
}
}
+our %unicode_entities;
+# set entities corresponding to unicode_map
+foreach my $command (keys(%unicode_map)) {
+ $unicode_entities{$command}
+ = '&#'.hex($unicode_map{$command}).';'
+ if ($unicode_map{$command} ne '');
+}
+
+
our %transliterate_map = (
'00C5' => 'AA',
'00E5' => 'aa',
Index: init/book.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/init/book.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- init/book.pm 9 Oct 2011 00:49:38 -0000 1.1
+++ init/book.pm 10 Oct 2011 00:07:54 -0000 1.2
@@ -36,11 +36,23 @@
set_from_init_file('USE_NODES', undef);
set_from_init_file('USE_SECTIONS', 1);
-
set_from_init_file('BIG_RULE', '<hr>');
-my $NO_BULLET_LIST_CLASS = 'no-bullet';
+my ($book_previous_default_filename, $book_previous_file_name,
+ $book_unumbered_nr);
+
+sub book_init($)
+{
+ my $converter = shift;
+ $book_previous_default_filename = undef;
+ $book_previous_file_name = undef;
+ $book_unumbered_nr = 0;
+}
+
+texinfo_register_handler('init', \&book_init);
+
+my $NO_BULLET_LIST_CLASS = 'no-bullet';
sub book_print_up_toc($$)
{
@@ -241,9 +253,9 @@
return undef if ($converter->get_conf('NODE_FILENAMES')
or !$converter->get_conf('SPLIT'));
- if (defined($converter->{'book_previous_default_filename'})
- and ($filename eq $converter->{'book_previous_default_filename'})) {
- return $converter->{'book_previous_file_name'};
+ if (defined($book_previous_default_filename)
+ and ($filename eq $book_previous_default_filename)) {
+ return $book_previous_file_name;
}
my $prefix = $converter->{'document_name'};
@@ -257,11 +269,11 @@
$number .= '.' unless ($number =~ /\.$/);
$new_file_name = "${prefix}_$number" . 'html';
} else {
- $converter->{'book_unumbered_nr'}++;
- $new_file_name = "${prefix}_U." . $converter->{'book_unumbered_nr'} .
'.html';
+ $book_unumbered_nr++;
+ $new_file_name = "${prefix}_U." . $book_unumbered_nr . '.html';
}
- $converter->{'book_previous_default_filename'} = $filename;
- $converter->{'book_previous_file_name'} = $new_file_name;
+ $book_previous_default_filename = $filename;
+ $book_previous_file_name = $new_file_name;
return $new_file_name;
}
Index: init/chm.pm
===================================================================
RCS file: init/chm.pm
diff -N init/chm.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ init/chm.pm 10 Oct 2011 00:07:54 -0000 1.1
@@ -0,0 +1,378 @@
+# -*-perl-*-
+
+#+##############################################################################
+#
+# chm.pm: convert to chm intermediate formats hhp, hhc, hhk and html files
+#
+# Copyright (C) 2004, 2006, 2009 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License,
+# or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Originally written by Patrice Dumas.
+#
+#-##############################################################################
+
+use strict;
+
+main::set_format('html');
+
+set_from_init_file('TOP_NODE_FILE', undef);
+set_from_init_file('TOP_FILE', undef);
+
+#$SECTION_NAVIGATION = 0; # to avoid headers in normal elements
+set_from_init_file('SHOW_MENU', 0);
+set_from_init_file('SPLIT', 'node');
+set_from_init_file('contents', 1);
+set_from_init_file('SPLIT_INDEX', undef);
+
+set_from_init_file('DEFAULT_RULE', '');
+set_from_init_file('BIG_RULE', '');
+set_from_init_file('HEADERS', 0);
+
+set_from_init_file('footnotestyle', 'end');
+
+#FIXME remove that later?
+set_from_init_file('USE_NODES', 0);
+#set_from_init_file('USE_SECTIONS', 1);
+
+use vars qw(%commands_formatting $end_file $navigation_header
+ $navigation_header_panel);
+$end_file = \&chm_end_file;
+# no-ops to avoid headers and footers
+$navigation_header = \&chm_noop;
+$navigation_header_panel = \&chm_noop;
+
+my %chm_languages = (
+ 'en' => '0x409 English (United States)',
+ 'sq' => '0x041c Albanian',
+# 'ar' => '0x1401 Arabic (ALGERIA)',
+# 'es' => '0x2c0a Spanish (ARGENTINA)',
+# 'en' => '0x0c09 English (AUSTRALIA)',
+# 'de' => '0x0c07 German (AUSTRIA)',
+# 'ar' => '0x3c01 Arabic (BAHRAIN)',
+ 'be' => '0x0423 Byelorussian',
+# 'fr' => '0x080c French (BELGIUM)',
+# 'en' => '0x2809 English (BELIZE)',
+# 'es' => '0x400a Spanish (BOLIVIA)',
+# 'pt' => '0x0416 Portuguese (BRAZIL)',
+# 'ms' => '0x083e Malay (BRUNEI DARUSSALAM)',
+ 'bg' => '0x0402 Bulgarian',
+# 'fr' => '0x0c0c French (CANADA)',
+# 'es' => '0x340a Spanish (CHILE)',
+ 'zh' => '0x0804 Chinese (CHINA)',
+# 'es' => '0x240a Spanish (COLOMBIA)',
+# 'es' => '0x140a Spanish (COSTA RICA)',
+ 'hr' => '0x041a Croatian',
+ 'cs' => '0x0405 Czech',
+ 'da' => '0x0406 Danish',
+# 'es' => '0x1c0a Spanish (DOMINICAN REPUBLIC)',
+# 'es' => '0x300a Spanish (ECUADOR)',
+# 'ar' => '0x0c01 Arabic (EGYPT)',
+# 'es' => '0x440a Spanish (EL SALVADOR)',
+ 'et' => '0x0425 Estonian',
+ 'fo' => '0x0438 Faeroese',
+ 'fi' => '0x040b Finnish',
+ 'fr' => '0x040c French (FRANCE)',
+ 'de' => '0x0407 German (GERMANY)',
+ 'el' => '0x0408 Greek',
+# 'es' => '0x100a Spanish (GUATEMALA)',
+# 'es' => '0x480a Spanish (HONDURAS)',
+# 'zh' => '0x0c04 Chinese (HONG KONG)',
+ 'hu' => '0x040e Hungarian',
+ 'is' => '0x040f Icelandic',
+ 'hi' => '0x0439 Hindi',
+ 'in' => '0x04',
+ 'fa' => '0x0429 Farsi',
+# 'ar' => '0x0801 Arabic (IRAQ)',
+# 'en' => '0x1809 English (IRELAND)',
+ 'iw' => '0x04',
+ 'it' => '0x0410 Italian',
+# 'en' => '0x2009 English (JAMAICA)',
+ 'ja' => '0x0411 Japanese',
+# 'ar' => '0x2c01 Arabic (JORDAN)',
+ 'sw' => '0x0441 Swahili',
+ 'ko' => '0x0412 Korean',
+# 'ar' => '0x3401 Arabic (KUWAIT)',
+ 'al' => '0x0426 Latvian (Lettish)',
+# 'ar' => '0x3001 Arabic (LEBANON)',
+# 'ar' => '0x1001 Arabic (LIBYAN ARAB JAMAHIRIYA)',
+# 'de' => '0x1407 German (LIECHTENSTEIN)',
+ 'lt' => '0x0427 Lithuanian',
+# 'de' => '0x1007 German (LUXEMBOURG)',
+# 'zh' => '0x1404 Chinese (MACAU)',
+ 'mk' => '0x042f Macedonian',
+# 'ms' => '0x043e Malay (MALAYSIA)',
+# 'es' => '0x080a Spanish (MEXICO)',
+# 'fr' => '0x180c French (MONACO)',
+# 'ar' => '0x1801 Arabic (MOROCCO)',
+ 'nl' => '0x0413 Dutch',
+# 'en' => '0x1409 English (NEW ZEALAND)',
+# 'es' => '0x4c0a Spanish (NICARAGUA)',
+ 'no' => '0x0414 Norwegian',
+# 'ar' => '0x2001 Arabic (OMAN)',
+ 'ur' => '0x0420 Urdu',
+# 'es' => '0x180a Spanish (PANAMA)',
+# 'es' => '0x3c0a Spanish (PARAGUAY)',
+# 'es' => '0x280a Spanish (PERU)',
+# 'en' => '0x3409 English (PHILIPPINES)',
+ 'pl' => '0x0415 Polish',
+ 'pt' => '0x0816 Portuguese (PORTUGAL)',
+# 'es' => '0x500a Spanish (PUERTO RICO)',
+# 'ar' => '0x4001 Arabic (QATAR)',
+ 'ro' => '0x0418 Romanian',
+ 'ru' => '0x0419 Russian',
+ 'ar' => '0x0401 Arabic (SAUDI ARABIA)',
+# 'zh' => '0x1004 Chinese (SINGAPORE)',
+ 'sk' => '0x041b Slovak',
+ 'sl' => '0x0424 Slovenian',
+ 'af' => '0x0436 Afrikaans',
+ 'ca' => '0x0403 Catalan',
+ 'sv' => '0x041d Swedish',
+# 'de' => '0x0807 German (SWITZERLAND)',
+# 'ar' => '0x2801 Arabic (SYRIAN ARAB REPUBLIC)',
+# 'zh' => '0x0404 Chinese (TAIWAN, PROVINCE OF CHINA)',
+ 'th' => '0x041e Thai',
+# 'en' => '0x2c09 English (TRINIDAD AND TOBAGO)',
+# 'ar' => '0x1c01 Arabic (TUNISIA)',
+ 'tr' => '0x041f Turkish',
+ 'uk' => '0x0422 Ukrainian',
+# 'ar' => '0x3801 Arabic (UNITED ARAB EMIRATES)',
+# 'en' => '0x0809 English (UNITED KINGDOM)',
+# 'en' => '0x0409 English (UNITED STATES)',
+# 'es' => '0x380a Spanish (URUGUAY)',
+# 'es' => '0x200a Spanish (VENEZUELA)',
+ 'vi' => '0x242a Vietnamese',
+# 'ar' => '0x2401 Arabic (YEMEN)',
+# 'en' => '0x3009 English (ZIMBABWE)',
+ #'' => '',
+);
+
+my %hhk_global_property = (
+ 'ImageType' => 'Folder',
+);
+
+my %hhc_global_property = (
+ 'ImageType' => 'Folder',
+);
+
+
+# at least kchmviewer has trouble with the corresponding textual entities
+foreach my $thing ('OE', 'oe', 'euro') {
+ $commands_formatting{'normal'}->{$thing}
+ = $Texinfo::Convert::Unicode::unicode_entities{$thing};
+}
+
+sub chm_end_file($)
+{
+ my $self = shift;
+ my $pre_body_close = $self->get_conf('PRE_BODY_CLOSE');
+ $pre_body_close = '' if (!defined($pre_body_close));
+ return "<p>
+$pre_body_close
+</p>
+</body>
+</html>
+";
+}
+
+sub chm_noop($$)
+{
+ return '';
+}
+
+sub convert_tree ($$;$)
+{
+ my $converter = shift;
+ my $tree = shift;
+ my $options = shift;
+
+ $options = {} if (!defined($options));
+
+ return $converter->protect_text(
+ Texinfo::Convert::Text::convert($tree,
+ {Texinfo::Common::_convert_text_options($converter),
+ %$options}));
+}
+
+sub chm_init($)
+{
+ my $self = shift;
+ return if (defined($self->get_conf('OUTFILE'))
+ and $Texinfo::Common::null_device_file{$self->get_conf('OUTFILE')});
+ my $document_name = $self->{'document_name'};
+ 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'});
+ # Not sure $! is still valid
+ if (!defined($hhk_fh)) {
+ die sprintf($self->__("Can't open %s for writing: %s\n"),
+ $hhk_file, $!);
+ }
+ print "# writing HTML Help index in $hhk_file...\n"
+ if ($self->get_conf('VERBOSE'));
+ print $hhk_fh "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n<HTML>\n";
+ print $hhk_fh "<HEAD>\n<meta name=\"GENERATOR\" content=\""
+ .$self->get_conf('PROGRAM') ."\">\n";
+ print $hhk_fh "<!-- Sitemap 1.0 -->\n</HEAD>\n<BODY>\n";
+ print $hhk_fh "<OBJECT type=\"text/site properties\">\n";
+ foreach my $property (sort(keys(%hhk_global_property))) {
+ print $hhk_fh "<param name=\"$property\"
value=\"$hhk_global_property{$property}\">\n";
+ }
+ print $hhk_fh "</OBJECT>\n";
+
+ 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'});
+ # Not sure $! is still valid
+ if (!defined($hhp_fh)) {
+ die sprintf($self->__("Can't open %s for writing: %s\n"),
+ $hhp_file, $!);
+ }
+ print "# writing HTML Help project in $hhp_file...\n"
+ if ($self->get_conf('VERBOSE'));
+ my $language = $chm_languages{'en'};
+ my $documentlanguage = $self->get_conf('documentlanguage');
+ $documentlanguage =~ s/_.*//;
+ if (exists ($chm_languages{$documentlanguage})) {
+ $language = $chm_languages{$documentlanguage};
+ }
+ my $title = convert_tree($self, $self->{'title_tree'});
+ my $top_file = '';
+ my $top_element = $self->global_element('Top');
+ if ($top_element and $top_element->{'extra'}->{'element_command'}) {
+ $top_file
+ = $self->command_filename($top_element->{'extra'}->{'element_command'});
+ }
+
+ print $hhp_fh <<EOT;
+[OPTIONS]
+Compatibility=1.1 or later
+Compiled file=$document_name.chm
+Contents file=$document_name.hhc
+Default Window=Default
+Default topic=$top_file
+Display compile progress=No
+Full-text search=Yes
+Index file=$hhk_filename
+Language=$language
+Title=$title
+
+[WINDOWS]
+Default=,"$document_name.hhc","$hhk_filename","$top_file","$top_file",,,,,0x22520,,0x384e,,,,,,,,0
+
+[FILES]
+EOT
+
+ my %chm_files;
+ if ($self->{'elements'}) {
+ foreach my $element (@{$self->{'elements'}}) {
+ if (!$chm_files{$element->{'filename'}}) {
+ print $hhp_fh "$element->{'filename'}\n";
+ $chm_files{$element->{'filename'}} = 1;
+ }
+ }
+ }
+ close ($hhp_fh);
+
+ 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'});
+ # Not sure $! is still valid
+ if (!defined($hhc_fh)) {
+ die sprintf($self->__("Can't open %s for writing: %s\n"),
+ $hhc_file, $!);
+ }
+ print "# writing HTML Help project in $hhc_file...\n"
+ if ($self->get_conf('VERBOSE'));
+
+ my $index_entries = Texinfo::Structuring::sort_indices($self,
+ $self->{'index_entries'},
+ $self->{'index_names'});
+ if ($index_entries) {
+ foreach my $index_name (keys (%$index_entries)) {
+ foreach my $index_entry_ref (@{$index_entries->{$index_name}}) {
+ my $file = $self->command_filename($index_entry_ref->{'command'});
+ my $anchor = $self->command_target($index_entry_ref->{'command'});
+ my $origin_href = "$file#$anchor";
+ my $entry = convert_tree($self,
+ {'contents' => $index_entry_ref->{'content'}},
+ {'code' => $index_entry_ref->{'in_code'}});
+ print $hhk_fh "<LI> <OBJECT type=\"text/sitemap\">\n<param
name=\"Name\" value=\"$entry\">\n<param name=\"Local\"
value=\"$origin_href\">\n</OBJECT> </LI>\n"
+ if ($entry =~ /\S/);
+ }
+ }
+ }
+ print $hhk_fh "</BODY>\n</HTML>\n";
+ close ($hhk_fh);
+
+ print $hhc_fh "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n<HTML>\n";
+ print $hhc_fh "<HEAD>\n<meta name=\"GENERATOR\" content=\""
+ .$self->get_conf('PROGRAM') ."\">\n";
+ print $hhc_fh "<!-- Sitemap 1.0 -->\n</HEAD>\n<BODY>\n";
+ print $hhc_fh "<OBJECT type=\"text/site properties\">\n";
+ foreach my $property (sort(keys(%hhc_global_property))) {
+ print $hhc_fh "<param name=\"$property\"
value=\"$hhc_global_property{$property}\">\n";
+
+ }
+ print $hhc_fh "</OBJECT>\n";
+
+ if ($self->{'structuring'} and $self->{'structuring'}->{'sectioning_root'}) {
+ my $section_root = $self->{'structuring'}->{'sectioning_root'};
+ my $upper_level = $section_root->{'section_childs'}->[0]->{'level'};
+ foreach my $top_section(@{$section_root->{'section_childs'}}) {
+ $upper_level = $top_section->{'level'}
+ if ($top_section->{'level'} < $upper_level);
+ }
+ $upper_level = 1 if ($upper_level <= 0);
+ my $root_level = $upper_level - 1;
+ my $level = $root_level;
+ foreach my $section (@{$self->{'structuring'}->{'sections_list'}}) {
+ next if ($section->{'cmdname'} eq 'part');
+ my $section_level = $section->{'level'};
+ $section_level = 1 if ($section_level == 0);
+ if ($level < $section_level) {
+ while ($level < $section_level) {
+ print $hhc_fh "<UL>\n";
+ $level++;
+ }
+ } elsif ($level > $section->{'level'}) {
+ while ($level > $section_level) {
+ print $hhc_fh "</UL>\n";
+ $level--;
+ }
+ }
+ my $text = convert_tree($self,
+ {'contents' => $section->{'extra'}->{'misc_content'}});
+ $text = Texinfo::Convert::Text::numbered_heading($section, $text,
+ $self->get_conf('NUMBER_SECTIONS'));
+ my $file = $self->command_filename($section);
+ my $anchor = $self->command_target($section);
+ my $origin_href = "$file#$anchor";
+ print $hhc_fh "<LI> <OBJECT type=\"text/sitemap\">\n<param name=\"Name\"
value=\"$text\">\n<param name=\"Local\" value=\"$origin_href\">\n</OBJECT>
</LI>\n";
+ }
+ while ($level > $root_level) {
+ print $hhc_fh "</UL>\n";
+ $level--;
+ }
+ }
+ print $hhc_fh "</HTML>\n</BODY>\n";
+}
+texinfo_register_handler('init', \&chm_init);
+
+
+1;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- texinfo/tp Makefile.am TODO texi2any.pl Texinfo...,
Patrice Dumas <=