[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Texi2html-cvs] texi2html ChangeLog Makefile.am Makefile.in NEW...
From: |
Patrice Dumas |
Subject: |
[Texi2html-cvs] texi2html ChangeLog Makefile.am Makefile.in NEW... |
Date: |
Fri, 22 May 2009 18:50:31 +0000 |
CVSROOT: /cvsroot/texi2html
Module name: texi2html
Changes by: Patrice Dumas <pertusus> 09/05/22 18:50:30
Modified files:
. : ChangeLog Makefile.am Makefile.in NEWS
buildt2h.sh texi2html.init texi2html.pl
examples : makeinfo.init
test : run_test.sh
Added files:
formats : docbook.init html.init info.init xml.init
Removed files:
examples : docbook.init info.init xml.init
Log message:
* texi2html.pl, texi2html.init, formats/html.init,
formats/info.init, addformats.sh, Makefile.am: put html
specific
formating in formats/html.init, and setup dynamically the
output
format, based on the command name and the option like --xml.
* examples/docbook.init,examples/info.init,examples/xml.init:
moved to formats/.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texi2html/ChangeLog?cvsroot=texi2html&r1=1.385&r2=1.386
http://cvs.savannah.gnu.org/viewcvs/texi2html/Makefile.am?cvsroot=texi2html&r1=1.46&r2=1.47
http://cvs.savannah.gnu.org/viewcvs/texi2html/Makefile.in?cvsroot=texi2html&r1=1.67&r2=1.68
http://cvs.savannah.gnu.org/viewcvs/texi2html/NEWS?cvsroot=texi2html&r1=1.98&r2=1.99
http://cvs.savannah.gnu.org/viewcvs/texi2html/buildt2h.sh?cvsroot=texi2html&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/texi2html/texi2html.init?cvsroot=texi2html&r1=1.197&r2=1.198
http://cvs.savannah.gnu.org/viewcvs/texi2html/texi2html.pl?cvsroot=texi2html&r1=1.287&r2=1.288
http://cvs.savannah.gnu.org/viewcvs/texi2html/examples/makeinfo.init?cvsroot=texi2html&r1=1.28&r2=1.29
http://cvs.savannah.gnu.org/viewcvs/texi2html/examples/docbook.init?cvsroot=texi2html&r1=1.21&r2=0
http://cvs.savannah.gnu.org/viewcvs/texi2html/examples/info.init?cvsroot=texi2html&r1=1.42&r2=0
http://cvs.savannah.gnu.org/viewcvs/texi2html/examples/xml.init?cvsroot=texi2html&r1=1.17&r2=0
http://cvs.savannah.gnu.org/viewcvs/texi2html/formats/docbook.init?cvsroot=texi2html&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/texi2html/formats/html.init?cvsroot=texi2html&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/texi2html/formats/info.init?cvsroot=texi2html&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/texi2html/formats/xml.init?cvsroot=texi2html&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/texi2html/test/run_test.sh?cvsroot=texi2html&r1=1.13&r2=1.14
Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/texi2html/texi2html/ChangeLog,v
retrieving revision 1.385
retrieving revision 1.386
diff -u -b -r1.385 -r1.386
--- ChangeLog 21 May 2009 20:15:54 -0000 1.385
+++ ChangeLog 22 May 2009 18:50:27 -0000 1.386
@@ -1,3 +1,12 @@
+2009-05-22 Patrice Dumas <address@hidden>
+
+ * texi2html.pl, texi2html.init, formats/html.init,
+ formats/info.init, addformats.sh, Makefile.am: put html specific
+ formating in formats/html.init, and setup dynamically the output
+ format, based on the command name and the option like --xml.
+ * examples/docbook.init,examples/info.init,examples/xml.init:
+ moved to formats/.
+
2009-05-21 Patrice Dumas <address@hidden>
* texi2html.pl, texi2html.init, examples/*, T2h_l2h.pm:
Index: Makefile.am
===================================================================
RCS file: /cvsroot/texi2html/texi2html/Makefile.am,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -b -r1.46 -r1.47
--- Makefile.am 2 Apr 2009 09:13:47 -0000 1.46
+++ Makefile.am 22 May 2009 18:50:27 -0000 1.47
@@ -18,9 +18,16 @@
examples/l2h.init \
T2h_l2h.pm
+texi2html_formats = \
+ formats/html.init \
+ formats/info.init \
+ formats/docbook.init \
+ formats/xml.init
+
texi2html_sources = texi2html_configured.pl $(texi2html_additional_scripts)
-noinst_SCRIPTS = manage_i18n.pl buildt2h.sh parse_8bit_makeinfo_maps.pl
+noinst_SCRIPTS = manage_i18n.pl buildt2h.sh addformats.sh \
+ parse_8bit_makeinfo_maps.pl
EXTRA_DIST = \
MySimple.pod \
@@ -31,7 +38,8 @@
texi2html.spec \
texi2html.spec.in \
texi2html.pl \
- $(texi2html_additional_scripts)
+ $(texi2html_additional_scripts) \
+ $(texi2html_formats)
dist_pkgdata_DATA = examples/l2h.init \
examples/makeinfo.init \
@@ -44,10 +52,7 @@
examples/enable_encoding.init \
examples/chm.init \
examples/roff.init \
- examples/xml.init \
- examples/info.init \
examples/mediawiki.init \
- examples/docbook.init \
examples/tex4ht.init \
examples/my-bib-macros.texi \
examples/bib-example.texi \
@@ -144,8 +149,11 @@
# -e "/@T2H_I18N@/r $(srcdir)/T2h_i18n.pm" \
# -e "/@T2H_L2H@/r $(srcdir)/T2h_l2h.pm" $< >$@
# chmod a+x $@
-texi2html: $(texi2html_sources)
+texi2html.interm: $(texi2html_sources)
$(SHELL) $(srcdir)/buildt2h.sh $@ $^
+
+texi2html: texi2html.interm $(texi2html_formats)
+ $(SHELL) $(srcdir)/addformats.sh $@ $^
chmod a+x $@
texi2html.spec: texi2html.spec.in configure
@@ -171,4 +179,4 @@
html-local: texi2html
clean-local:
- -rm -f texi2html
+ -rm -f texi2html texi2html.interm
Index: Makefile.in
===================================================================
RCS file: /cvsroot/texi2html/texi2html/Makefile.in,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -b -r1.67 -r1.68
--- Makefile.in 27 Apr 2009 17:14:04 -0000 1.67
+++ Makefile.in 22 May 2009 18:50:27 -0000 1.68
@@ -192,8 +192,16 @@
examples/l2h.init \
T2h_l2h.pm
+texi2html_formats = \
+ formats/html.init \
+ formats/info.init \
+ formats/docbook.init \
+ formats/xml.init
+
texi2html_sources = texi2html_configured.pl $(texi2html_additional_scripts)
-noinst_SCRIPTS = manage_i18n.pl buildt2h.sh parse_8bit_makeinfo_maps.pl
+noinst_SCRIPTS = manage_i18n.pl buildt2h.sh addformats.sh \
+ parse_8bit_makeinfo_maps.pl
+
EXTRA_DIST = \
MySimple.pod \
autogen.sh \
@@ -203,7 +211,8 @@
texi2html.spec \
texi2html.spec.in \
texi2html.pl \
- $(texi2html_additional_scripts)
+ $(texi2html_additional_scripts) \
+ $(texi2html_formats)
dist_pkgdata_DATA = examples/l2h.init \
examples/makeinfo.init \
@@ -216,10 +225,7 @@
examples/enable_encoding.init \
examples/chm.init \
examples/roff.init \
- examples/xml.init \
- examples/info.init \
examples/mediawiki.init \
- examples/docbook.init \
examples/tex4ht.init \
examples/my-bib-macros.texi \
examples/bib-example.texi \
@@ -824,8 +830,11 @@
# -e "/@T2H_I18N@/r $(srcdir)/T2h_i18n.pm" \
# -e "/@T2H_L2H@/r $(srcdir)/T2h_l2h.pm" $< >$@
# chmod a+x $@
-texi2html: $(texi2html_sources)
+texi2html.interm: $(texi2html_sources)
$(SHELL) $(srcdir)/buildt2h.sh $@ $^
+
+texi2html: texi2html.interm $(texi2html_formats)
+ $(SHELL) $(srcdir)/addformats.sh $@ $^
chmod a+x $@
texi2html.spec: texi2html.spec.in configure
@@ -851,7 +860,7 @@
html-local: texi2html
clean-local:
- -rm -f texi2html
+ -rm -f texi2html texi2html.interm
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
Index: NEWS
===================================================================
RCS file: /cvsroot/texi2html/texi2html/NEWS,v
retrieving revision 1.98
retrieving revision 1.99
diff -u -b -r1.98 -r1.99
--- NEWS 21 May 2009 20:15:54 -0000 1.98
+++ NEWS 22 May 2009 18:50:27 -0000 1.99
@@ -7,6 +7,8 @@
* new info backend, ready for world domination!
+* main program handles --xml, --docbook, --info and html.
+
* Handle @DH{}, @dh{}, @TH{}, @th{}.
* Handle -o /dev/null (or NUL) like makeinfo.
Index: buildt2h.sh
===================================================================
RCS file: /cvsroot/texi2html/texi2html/buildt2h.sh,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- buildt2h.sh 28 Jan 2006 22:02:26 -0000 1.2
+++ buildt2h.sh 22 May 2009 18:50:27 -0000 1.3
@@ -11,4 +11,5 @@
-e "/@INIT@/r $5" \
-e "/@T2H_TRANSLATIONS_FILE@/r $6" \
-e "/@T2H_L2H_INIT@/r $7" \
- -e "/@T2H_L2H@/r $8" $2 >$1
+ -e "/@T2H_L2H@/r $8" \
+ $2 >$1
Index: texi2html.init
===================================================================
RCS file: /cvsroot/texi2html/texi2html/texi2html.init,v
retrieving revision 1.197
retrieving revision 1.198
diff -u -b -r1.197 -r1.198
--- texi2html.init 21 May 2009 20:49:04 -0000 1.197
+++ texi2html.init 22 May 2009 18:50:27 -0000 1.198
@@ -12,7 +12,7 @@
# Afterwards, load the file with command-line
# option -init-file <your_init_file>
#
-# $Id: texi2html.init,v 1.197 2009/05/21 20:49:04 pertusus Exp $
+# $Id: texi2html.init,v 1.198 2009/05/22 18:50:27 pertusus Exp $
######################################################################
# The following variables can also be set by command-line options
@@ -29,6 +29,114 @@
# options appearing before -init-file and might still be overwritten by
# command-line arguments following the -init-file option.
+##################################################################
+#Â options common with makeinfo
+# -I
+# add a directory to the list of directories where @include files are
+# searched for (besides the directory of the file). additional '-I'
+# args are appended to this list.
+# (APA: Don't implicitely search ., to conform with the docs!)
+# my @INCLUDE_DIRS = (".");
address@hidden = ();
+
+# -P
+# prepend a directory to the list of directories where @include files are
+# searched for before the directory of the file. additional '-P'
+# args are prepended to this list.
address@hidden = ();
+
+# -split section|chapter|node|none
+# if $SPLIT is set to 'section' (resp. 'chapter') one html file per section
+# (resp. chapter) is generated. If $SPLIT is set to 'node' one html file per
+# node or sectionning element is generated. In all these cases separate pages
+# for Top, Table of content (Toc), Overview and About are generated.
+# Otherwise a monolithic html file that contains the whole document is
+# created.
+#$SPLIT = 'section';
+$SPLIT = '';
+
+# -separated-footnotes
+# if this is set footnotes are on a separated page. Otherwise they are at
+# the end of each file (if the document is split).
+$FOOTNOTESTYLE = 'separate';
+
+# -fill-column
+$FILLCOLUMN = 72;
+
+# -number | -nonumber
+# if this is set the sections are numbered, and section names and numbers
+# are used in references and menus (instead of node names).
+$NUMBER_SECTIONS = 1;
+
+# -headers
+# if this is set then navigation panels are printed at the beginning of each
+# section.
+# If the document is split at nodes then navigation panels are
+# printed at the end if there were more than $WORDS_IN_PAGE words on page.
+#
+# Navigation panels are always printed at the beginning of output files.
+#
+# This is most useful if you do not want to have section navigation
+# with -split chapter. There will be chapter navigation panel at the
+# beginning and at the end of chapters anyway.
+$SECTION_NAVIGATION = 1;
+
+# -o filename
+# If this is set a monolithic document is outputted into $filename.
+$OUT = '';
+
+# --split-size
+#Â if undef, the info output is not split
+$SPLIT_SIZE = 300000;
+
+# --internal-links
+$INTERNAL_LINKS = undef;
+
+# -no-validate
+# suppress node cross-reference validation
+$NOVALIDATE = 0;
+
+# -documentlanguage
+# use &$I('my string') if you want to have translations of 'my string'
+# and provide the translations in $LANGUAGES->{$DOCUMENTLANGUAGE} with
+# 'my string' as key.
+# To add a new language use ISO 639 language codes (see e.g. perl module
+# Locale-Codes-1.02 for definitions). Supply translations in the
+# $LANGUAGES hash and put it in a file with $LANG as name in an i18n
+# directory.
+# This is used for the initial language, it is overriden during
+# document processing if there is a @documentlanguage.
+# It is ignored if the language is passed on the command line.
+$DOCUMENTLANGUAGE = 'en';
+
+# -transliterate-file-names
+# transliterate node names for external refs (and internal if NODE_FILES)
+$TRANSLITERATE_NODE = 1;
+
+# --error-limit
+# quit after NUM errors (default 1000).
+$ERROR_LIMIT = 1000;
+
+# -css-include
+# All the specified css files are used. More precisely the @import sections
+# are added to the beginning of the CSS_LINES the remaining is added at
+# the end of the CSS_LINES (after the css rules generated by texi2html).
+# cf texinfo manual for more info.
+# - means STDIN
address@hidden = ();
+
+# -css-ref
+# the specified url are used as stylesheet links
address@hidden = ();
+
+# --paragraph-indent
+$PARAGRAPHINDENT = 3;
+
+#Â --enable-encoding
+$ENABLE_ENCODING = 0;
+
+##################################################################
+#Â option specific of texi2html
# -debug
# The integer value specifies what kind of debugging output is generated.
$DEBUG = 0;
@@ -39,12 +147,12 @@
# Definition: The SystemLiteral is called the entity's system
# identifier. It is a URI, which may be used to retrieve the entity.
# See http://www.xml.com/axml/target.html#NT-ExternalID
-$DOCTYPE = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">';
+$DOCTYPE = '';
# -frameset-doctype
# When frames are used, this SystemLiteral identifies the DTD used for
# the file containing the frame description.
-$FRAMESET_DOCTYPE = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01
Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">';
+$FRAMESET_DOCTYPE = '';
# -test
# If this value is true, some variables which should be dynamically generated
@@ -61,7 +169,7 @@
# -expand
# the @EXPAND array contains the expanded section names.
address@hidden = ('html');
address@hidden = ('plaintext');
# -invisible
# This seems obsolete and is not used anywhere.
@@ -75,20 +183,6 @@
# (like copyright, etc).
$USE_ISO = 1;
-# -I
-# add a directory to the list of directories where @include files are
-# searched for (besides the directory of the file). additional '-I'
-# args are appended to this list.
-# (APA: Don't implicitely search ., to conform with the docs!)
-# my @INCLUDE_DIRS = (".");
address@hidden = ();
-
-# -P
-# prepend a directory to the list of directories where @include files are
-# searched for before the directory of the file. additional '-P'
-# args are prepended to this list.
address@hidden = ();
-
# --conf-dir
# append to the files searched for init files.
@CONF_DIRS = ();
@@ -116,11 +210,6 @@
# if the value is true the Texinfo menus are shown.
$SHOW_MENU = 1;
-# -number | -nonumber
-# if this is set the sections are numbered, and section names and numbers
-# are used in references and menus (instead of node names).
-$NUMBER_SECTIONS = 1;
-
# -use-nodes
# if this is set the nodes are used as sectionning elements.
# Otherwise the nodes are incorporated in sections.
@@ -134,37 +223,6 @@
# cross manual references.
$NODE_FILES = 0;
-# -split section|chapter|node|none
-# if $SPLIT is set to 'section' (resp. 'chapter') one html file per section
-# (resp. chapter) is generated. If $SPLIT is set to 'node' one html file per
-# node or sectionning element is generated. In all these cases separate pages
-# for Top, Table of content (Toc), Overview and About are generated.
-# Otherwise a monolithic html file that contains the whole document is
-# created.
-#$SPLIT = 'section';
-$SPLIT = '';
-
-# -sec-nav|-nosec-nav
-# if this is set then navigation panels are printed at the beginning of each
-# section.
-# If the document is split at nodes then navigation panels are
-# printed at the end if there were more than $WORDS_IN_PAGE words on page.
-#
-# Navigation panels are always printed at the beginning of output files.
-#
-# This is most useful if you do not want to have section navigation
-# with -split chapter. There will be chapter navigation panel at the
-# beginning and at the end of chapters anyway.
-$SECTION_NAVIGATION = 1;
-
-# -separated-footnotes
-# if this is set footnotes are on a separated page. Otherwise they are at
-# the end of each file (if the document is split).
-$FOOTNOTESTYLE = 'separate';
-
-# -fill-column
-$FILLCOLUMN = 72;
-
# -toc-links
# if this is set, links from headings to toc entries are created.
$TOC_LINKS = 0;
@@ -185,21 +243,6 @@
# By default, this is the basename of the document.
$PREFIX = '';
-# -o filename
-# If this is set a monolithic document is outputted into $filename.
-$OUT = '';
-
-# --split-size
-#Â if undef, the info output is not split
-$SPLIT_SIZE = 300000;
-
-# --internal-links
-$INTERNAL_LINKS = undef;
-
-# -no-validate
-# suppress node cross-reference validation
-$NOVALIDATE = 0;
-
# -short-ref
# if this is set cross-references are given without section numbers.
$SHORT_REF = '';
@@ -220,19 +263,6 @@
# if this is set chatter about what we are doing.
$VERBOSE = '';
-# -lang
-# use &$I('my string') if you want to have translations of 'my string'
-# and provide the translations in $LANGUAGES->{$DOCUMENTLANGUAGE} with
-# 'my string' as key.
-# To add a new language use ISO 639 language codes (see e.g. perl module
-# Locale-Codes-1.02 for definitions). Supply translations in the
-# $LANGUAGES hash and put it in a file with $LANG as name in an i18n
-# directory.
-# This is used for the initial language, it is overriden during
-# document processing if there is a @documentlanguage.
-# It is ignored if the language is passed on the command line.
-$DOCUMENTLANGUAGE = 'en';
-
# -ignore-preamble-text
# If this is set the text before @node and sectionning commands is ignored.
$IGNORE_PREAMBLE_TEXT = 0;
@@ -246,30 +276,10 @@
# if this is set, latex2html is used for generation of math content.
$L2H = '';
-# -transliterate-file-names
-# transliterate node names for external refs (and internal if NODE_FILES)
-$TRANSLITERATE_NODE = 1;
-
-# --error-limit
-# quit after NUM errors (default 1000).
-$ERROR_LIMIT = 1000;
-
# -monolithic
# output only one file including ToC. It only makes sense when not split
$MONOLITHIC = 1;
-# -css-include
-# All the specified css files are used. More precisely the @import sections
-# are added to the beginning of the CSS_LINES the remaining is added at
-# the end of the CSS_LINES (after the css rules generated by texi2html).
-# cf texinfo manual for more info.
-# - means STDIN
address@hidden = ();
-
-# -css-ref
-# the specified url are used as stylesheet links
address@hidden = ();
-
######################
# The following options are only relevant if $L2H is set
#
@@ -297,11 +307,6 @@
# latex2html are cleaned (they all have the prefix <document name>_l2h_).
$L2H_CLEAN = 1;
-$PARAGRAPHINDENT = 3;
-$FIRSTPARAGRAPHINDENT = 'none';
-
-$ENABLE_ENCODING = 0;
-
##############################################################################
#
# The following can only be set in the init file
@@ -310,6 +315,8 @@
@INPUT_FILE_SUFFIXES = ('.txi','.texinfo','.texi','.txinfo','');
+$FIRSTPARAGRAPHINDENT = 'none';
+
# If true do table of contents even if there is no @content
$CONTENTS = undef;
@@ -369,19 +376,19 @@
# used as identation for block enclosing command @example, etc
# If not empty, must be enclosed in <td></td>
-$EXAMPLE_INDENT_CELL = '<td> </td>';
+$EXAMPLE_INDENT_CELL = '';
# same as above, only for @small
-$SMALL_EXAMPLE_INDENT_CELL = '<td> </td>';
+$SMALL_EXAMPLE_INDENT_CELL = '';
# font size for @small
$SMALL_FONT_SIZE = '-1';
# horizontal rules
-$SMALL_RULE = '<hr size="1">';
-$DEFAULT_RULE = '<hr>';
-$MIDDLE_RULE = '<hr size="2">';
-$BIG_RULE = '<hr size="6">';
+$SMALL_RULE = '';
+$DEFAULT_RULE = '';
+$MIDDLE_RULE = '';
+$BIG_RULE = '';
# if non-empty, and no @..heading appeared in Top node, then
# use this as header for top node/section, otherwise use value of
@@ -398,10 +405,10 @@
# symbol put at the beginning of nodes entry in menu (and optionnaly of
# unnumbered in menus, see next variable)
-$MENU_SYMBOL = '•';
+$MENU_SYMBOL = '*';
#$MENU_SYMBOL = '*';
-$SIMPLE_MENU = 0;
+$SIMPLE_MENU = 1;
$OPEN_QUOTE_SYMBOL = "\`";
$CLOSE_QUOTE_SYMBOL = "'";
@@ -412,10 +419,10 @@
$UNNUMBERED_SYMBOL_IN_MENU = 0;
# extension for nodes files when NODE_FILES is true
-$NODE_FILE_EXTENSION = 'html';
+$NODE_FILE_EXTENSION = 'txt';
# extension
-$EXTENSION = 'html';
+$EXTENSION = 'txt';
# file name used for Top node when NODE_FILES is true
$TOP_NODE_FILE = 'index';
@@ -448,12 +455,12 @@
$NO_BULLET_LIST_ATTRIBUTE = ' class="toc"';
# These lines are inserted before and after the shortcontents
-$BEFORE_OVERVIEW = "<div class=\"shortcontents\">\n";
-$AFTER_OVERVIEW = "</div>\n";
+$BEFORE_OVERVIEW = "";
+$AFTER_OVERVIEW = "";
# These lines are inserted before and after the contents
-$BEFORE_TOC_LINES = "<div class=\"contents\">\n";
-$AFTER_TOC_LINES = "</div>\n";
+$BEFORE_TOC_LINES = "";
+$AFTER_TOC_LINES = "";
# if set (e.g., to index.html) replace hrefs to this file
# (i.e., to index.html) by ./
@@ -593,9 +600,7 @@
'PrevFile', '',
);
address@hidden = ('png','jpg','jpeg','gif');
-#, 'txt');
-
address@hidden = ('png','jpg', 'txt');
%misc_pages_targets = (
'Overview' => 'SEC_Overview',
@@ -619,7 +624,6 @@
$init_out = \&t2h_default_init_out;
$finish_out = \&t2h_default_finish_out;
-
$translate_names = \&t2h_default_translate_names;
sub t2h_default_translate_names()
@@ -852,14 +856,6 @@
@t2h_default_multitable_stack = ();
&$translate_names;
# Set the default body text, inserted between <body ... >
- if (defined($BODYTEXT))
- {
- $Texi2HTML::THISDOC{'BODYTEXT'} = $BODYTEXT;
- }
- else
- {
- $Texi2HTML::THISDOC{'BODYTEXT'} = 'lang="' .
get_conf('documentlanguage') . '" bgcolor="#FFFFFF" text="#000000"
link="#0000FF" vlink="#800080" alink="#FF0000"';
- }
if (!defined($EXTERNAL_CROSSREF_SPLIT))
{
if (get_conf('SPLIT'))
@@ -878,34 +874,27 @@
t2h_default_set_out_encoding();
- # not in code_style, according to post on bug-texinfo
- if ($SIMPLE_MENU)
- {
- foreach my $format ('menu', 'detailmenu', 'direntry')
- {
- if (!defined($complex_format_map->{$format}))
+}
+
+my %t2h_default_formats_load_table = (
+ 'html' => \&html_default_load,
+ 'info' => \&info_default_load,
+ 'docbook' => \&docbook_default_load,
+ 'xml' => \&xml_default_load,
+);
+
+sub t2h_default_load_format($)
+{
+ my $format = shift;
+ if (defined($t2h_default_formats_load_table{$format}))
{
- $complex_format_map->{$format} = { 'begin' => q{''} , 'end' =>
q{''},
- 'pre_style' => "$MENU_PRE_STYLE", 'class' =>
'menu-preformatted',
-# 'style' => 'code'
- };
- }
+ &{$t2h_default_formats_load_table{$format}};
}
- #$SEPARATE_DESCRIPTION = 1;
- #$format_map{'menu_comment'} = '' if
(!defined($format_map{'menu_comment'}));
- }
- elsif (!defined($format_map{'menu_comment'}) and
!defined($complex_format_map->{'menu_comment'}))
- {
- $complex_format_map->{'menu_comment'} =
+ else
{
- 'begin' => q{"<tr><th colspan=\"3\" align=\"left\"
valign=\"top\">"},
- 'end' => q{"</th></tr>"}, 'pre_style' => "$MENU_PRE_STYLE", 'class'
=> 'menu-comment',
-# 'style' => 'code'
- }
+ warn "Unkown output format $format\n";
}
- # obsolete
- #return $OUT_ENCODING;
-};
+}
sub t2h_encoding_is_entity($)
{
@@ -999,8 +988,6 @@
#
#######################################################################
-$BODYTEXT = undef;
-
# default used in init_out for the setting of the ENCODING_NAME variable
$DEFAULT_ENCODING = 'utf8';
@@ -1145,16 +1132,8 @@
{
my $first_in_page = shift;
my $previous_is_top = shift;
- my $buttons = address@hidden;
- if (($first_in_page or $previous_is_top) and $SECTION_NAVIGATION)
- {
- return &$print_head_navigation(undef, $buttons);
- }
- else
- { # got to do this here, as it isn't done in print_head_navigation
- return &$print_navigation($buttons) if ($SECTION_NAVIGATION or
get_conf('SPLIT') eq 'node');
- }
+ return '';
}
sub T2H_DEFAULT_print_section
@@ -1163,19 +1142,8 @@
my $first_in_page = shift;
my $previous_is_top = shift;
my $element = shift;
- my $buttons = address@hidden;
my $nw = main::print_lines($fh);
- if ((get_conf('SPLIT') eq 'node') && $SECTION_NAVIGATION)
- {
- my $buttons = address@hidden;
- &$print_foot_navigation($fh, $buttons, $SMALL_RULE,
- (!defined($WORDS_IN_PAGE) or (defined ($nw) and $nw >=
$WORDS_IN_PAGE)),
- $element);
-# print $fh "$SMALL_RULE\n";
-# &$print_navigation($buttons) if (!defined($WORDS_IN_PAGE) or (defined
($nw)
-# and $nw >= $WORDS_IN_PAGE));
- }
}
sub T2H_DEFAULT_one_section($$)
@@ -1384,52 +1352,6 @@
sub T2H_DEFAULT_print_page_head($)
{
my $fh = shift;
- my $longtitle = "$Texi2HTML::THISDOC{'fulltitle_simple_format'}";
- $longtitle .= ": $Texi2HTML::SIMPLE_TEXT{'This'}" if (defined
($Texi2HTML::SIMPLE_TEXT{'This'}) and ($Texi2HTML::SIMPLE_TEXT{'This'} !~
/^\s*$/) and get_conf('SPLIT'));
- my $description = $Texi2HTML::THISDOC{'DOCUMENT_DESCRIPTION'};
- $description = $longtitle if (!defined($description));
- $description = "<meta name=\"description\" content=\"$description\">" if
- ($description ne '');
- my $encoding = '';
- $encoding = "<meta http-equiv=\"Content-Type\" content=\"text/html;
charset=$Texi2HTML::THISDOC{'ENCODING_NAME'}\">" if
(defined($Texi2HTML::THISDOC{'ENCODING_NAME'}) and
($Texi2HTML::THISDOC{'ENCODING_NAME'} ne ''));
- my $links = '';
- if ($USE_LINKS)
- {
- foreach my $link (@LINKS_BUTTONS)
- {
-#print STDERR "$link!!$Texi2HTML::HREF{$link}\n";
- if (defined($Texi2HTML::HREF{$link}) and $Texi2HTML::HREF{$link}
ne '')
- {
- my $title = '';
- $title = " title=\"$Texi2HTML::SIMPLE_TEXT{$link}\"" if
(defined($Texi2HTML::SIMPLE_TEXT{$link}));
- my $rel = '';
- $rel = " rel=\"$BUTTONS_REL{$link}\"" if
(defined($BUTTONS_REL{$link}));
- $links .= "<link
href=\"$Texi2HTML::HREF{$link}\"${rel}${title}>\n";
- }
- }
- }
-
- print $fh <<EOT;
-$DOCTYPE
-<html>
-$Texi2HTML::THISDOC{'copying_comment'}<!-- Created on
$Texi2HTML::THISDOC{today} by $Texi2HTML::THISDOC{program}
-$Texi2HTML::THISDOC{program_authors}-->
-<head>
-<title>$longtitle</title>
-
-$description
-<meta name="keywords" content="$longtitle">
-<meta name="resource-type" content="document">
-<meta name="distribution" content="global">
-<meta name="Generator" content="$Texi2HTML::THISDOC{program}">
-$encoding
-${links}$Texi2HTML::THISDOC{'CSS_LINES'}
-$EXTRA_HEAD
-</head>
-
-<body $Texi2HTML::THISDOC{'BODYTEXT'}>
-$AFTER_BODY_OPEN
-EOT
}
sub T2H_DEFAULT_program_string()
@@ -4322,6 +4244,21 @@
$complex_format_map->{'format'} = $complex_format_map->{'display'};
$complex_format_map->{'smallformat'} = $complex_format_map->{'smalldisplay'};
+# not in code_style, according to post on bug-texinfo
+foreach my $format ('menu', 'detailmenu', 'direntry')
+{
+ $complex_format_map->{$format} = { 'begin' => q{''} , 'end' => q{''},
+ 'pre_style' => "$MENU_PRE_STYLE", 'class' => 'menu-preformatted',
+ };
+}
+
+# not in code_style, according to post on bug-texinfo
+$complex_format_map->{'menu_comment'} = {
+ 'begin' => q{''},
+ 'end' => q{''}, 'pre_style' => "$MENU_PRE_STYLE", 'class' => 'menu-comment',
+};
+
+
%def_map = (
# basic commands
'deffn', [ 'f', 'category', 'name', 'arg' ],
@@ -5406,13 +5343,6 @@
return "<tr><td align=\"left\"
valign=\"top\">$entry</td><td> </td>";
}
-sub simplify_text($)
-{
- my $text = shift;
- $text =~ s/[^\w]//og;
- return $text;
-}
-
# formats a menu entry description, ie the text appearing after the node
# specification in a menu entry an spanning until there is another
# menu entry, an empty line or some text at the very beginning of the line
@@ -5437,34 +5367,11 @@
#return $text."<br>" if ($in_commands and !$state->{'preformatted'});
if ($AVOID_MENU_REDUNDANCY)
{
- $text = '' if (simplify_text($element_text) eq simplify_text($text));
+ $text = '' if (html_simplify_text($element_text) eq
html_simplify_text($text));
}
return "<td align=\"left\" valign=\"top\">$text</td></tr>\n";
}
-# a menu comment (between menu lines, obsolete)
-# formats the container of a menu comment. A menu comment is any text
-# appearing between menu lines, either separated by an empty line from
-# the preceding menu entry, or a text beginning at the first character
-# of the line (text not at the very beginning of the line is considered to
-# be the continuation of a menu entry description text).
-#
-# The text itself is considered to be in a preformatted environment
-# with name 'menu-commment' and with style $MENU_PRE_STYLE.
-#
-# argument
-# text contained in the menu comment.
-#sub t2h_default_menu_comment($)
-#{
-# my $text = shift;
-# return $text if ($SIMPLE_MENU);
-# if ($text =~ /\S/)
-# {
-# return "<tr><th colspan=\"3\" align=\"left\"
valign=\"top\">$text</th></tr>";
-# }
-# return '';
-#}
-
# Construct a href to an external source of information.
# node is the node with texinfo @-commands
# node_id is the node transliterated and transformed as explained in the
@@ -5764,18 +5671,6 @@
return '';
}
-sub teletyped_in_stack($)
-{
- my $stack = shift;
- foreach my $element(reverse(@$stack))
- {
- return 1 if ($complex_format_map->{$element} and
- $complex_format_map->{$element}->{'style'} and
- $complex_format_map->{$element}->{'style'} eq 'code');
- }
- return 0;
-}
-
# text after @item in table, vtable and ftable
sub t2h_default_table_item($$$$$$$)
{
@@ -5797,12 +5692,6 @@
# }
# $formatted_command = '' if (!defined($formatted_command) or
# exists($special_list_commands{$format}->{$command}));
- if (teletyped_in_stack($style_stack))
- {
-# $text .= '</tt>';
-# $formatted_command = '<tt>' . $formatted_command;
- $text = '<tt>' . $text . '</tt>';
- }
$text .= "\n" . $index_label if (defined($index_label));
# return '<dt>' . $formatted_command . $text . '</dt>' . "\n";
return '<dt>' . $text . '</dt>' . "\n";
Index: texi2html.pl
===================================================================
RCS file: /cvsroot/texi2html/texi2html/texi2html.pl,v
retrieving revision 1.287
retrieving revision 1.288
diff -u -b -r1.287 -r1.288
--- texi2html.pl 21 May 2009 20:49:04 -0000 1.287
+++ texi2html.pl 22 May 2009 18:50:28 -0000 1.288
@@ -86,7 +86,7 @@
}
# CVS version:
-# $Id: texi2html.pl,v 1.287 2009/05/21 20:49:04 pertusus Exp $
+# $Id: texi2html.pl,v 1.288 2009/05/22 18:50:28 pertusus Exp $
# Homepage:
my $T2H_HOMEPAGE = "http://www.nongnu.org/texi2html/";
@@ -194,6 +194,28 @@
# #
#---###########################################################################
+my $my_command_name = $0;
+$my_command_name =~ s/.*\///;
+$my_command_name =~ s/\.pl$//;
+
+my $default_output_format;
+
+my %command_format = (
+ 'texi2html' => 'html',
+ 'makeinfo' => 'info',
+);
+
+if ($command_format{$my_command_name})
+{
+ #$DEFAULT_OUTPUT_FORMAT = $command_format{$my_command_name};
+ $default_output_format = $command_format{$my_command_name};
+}
+
+sub default_output_format()
+{
+ return $default_output_format;
+}
+
{
package Texi2HTML::Config;
@@ -202,6 +224,16 @@
sub load($)
{
my $file = shift;
+ # FIXME temporary ugly hack. Otherwise the info related functions are
+ #Â redefined
+ foreach my $format('info', 'html', 'docbook', 'plaintext', 'xml')
+ {
+ if ($file =~ /\/$format\.init$/)
+ {
+ t2h_default_load_format($format);
+ return 1;
+ }
+ }
eval { require($file) ;};
if ($@ ne '')
{
@@ -283,6 +315,7 @@
$FIRSTPARAGRAPHINDENT
$ENABLE_ENCODING
$INTERNAL_LINKS
+$DEFAULT_OUTPUT_FORMAT
);
# customization variables
@@ -593,6 +626,8 @@
%t2h_encoding_aliases
);
+$DEFAULT_OUTPUT_FORMAT = main::default_output_format();
+
sub set_conf($$;$)
{
my $name = shift;
@@ -1298,6 +1333,29 @@
if ($0 =~ /\.pl$/ &&
-e "$T2H_HOME/texi2html.init" && -r "$T2H_HOME/texi2html.init");
address@hidden@
+
+require "$T2H_HOME/formats/html.init"
+ if ($0 =~ /\.pl$/ &&
+ -e "$T2H_HOME/formats/html.init" && -r "$T2H_HOME/formats/html.init");
+
+# @INIT_INFO@
+
+require "$T2H_HOME/formats/info.init"
+ if ($0 =~ /\.pl$/ &&
+ -e "$T2H_HOME/formats/info.init" && -r "$T2H_HOME/formats/info.init");
+
address@hidden@
+
+require "$T2H_HOME/formats/docbook.init"
+ if ($0 =~ /\.pl$/ &&
+ -e "$T2H_HOME/formats/docbook.init" && -r
"$T2H_HOME/formats/docbook.init");
+
address@hidden@
+
+require "$T2H_HOME/formats/xml.init"
+ if ($0 =~ /\.pl$/ &&
+ -e "$T2H_HOME/formats/xml.init" && -r "$T2H_HOME/formats/xml.init");
my $translation_file = 'translations.pl'; # file containing all the
translations
my $T2H_OBSOLETE_STRINGS;
@@ -2517,7 +2575,7 @@
noHelp => 1,
};
-$T2H_OPTIONS -> {'header'} =
+$T2H_OPTIONS -> {'headers'} =
{
type => '!',
linkage => \$Texi2HTML::Config::SECTION_NAVIGATION,
@@ -2783,6 +2841,24 @@
noHelp => 1
};
+my %output_format_names = (
+ 'info' => 'Info',
+ 'html' => 'HTML',
+ 'docbook' => 'Docbook XML',
+ 'xml' => 'Texinfo XML',
+ 'plaintext' => 'plain text',
+);
+
+foreach my $output_format (keys(%output_format_names))
+{
+ next if ($output_format eq $default_output_format);
+ $T2H_OPTIONS -> {$output_format} =
+ {
+ type => '',
+ linkage => sub {Texi2HTML::Config::t2h_default_load_format($_[0]);},
+ verbose => "output $output_format_names{$output_format} rather than
$output_format_names{$default_output_format}.",
+ }
+}
##
## obsolete cmd line options
@@ -3166,6 +3242,10 @@
#
#
#---############################################################################
+# load the chosen format
+
+#Texi2HTML::Config::t2h_default_load_format('html');
+
# set the default 'args' entry to normal for each style hash (and each command
# within)
my $name_index = -1;
@@ -9122,7 +9202,8 @@
add_prev($text, $stack,
&$Texi2HTML::Config::float($format_ref->{'text'}, $state->{'float'},
$caption_text, $shortcaption_text));
delete $state->{'float'};
}
- elsif (exists ($Texi2HTML::Config::complex_format_map->{$format}))
+ elsif (exists ($Texi2HTML::Config::complex_format_map->{$format}) and
+ ($format_type{$format} ne 'menu' or $Texi2HTML::Config::SIMPLE_MENU))
{
$state->{'preformatted'}--;
pop @{$state->{'preformatted_stack'}};
@@ -9447,7 +9528,8 @@
push @$stack, { 'format' => 'deff_item', 'text' => '',
'only_inter_commands' => 1, 'format_ref' => $top_format, 'orig_command' =>
$orig_command};
begin_paragraph_after_command($state, $stack, $macro, $line);
}
- elsif (exists ($Texi2HTML::Config::complex_format_map->{$macro}))
+ elsif (exists ($Texi2HTML::Config::complex_format_map->{$macro}) and
+ ($format_type{$macro} ne 'menu' or $Texi2HTML::Config::SIMPLE_MENU))
{ # handle menu if SIMPLE_MENU. see texi2html.init
my $complex_format = $Texi2HTML::Config::complex_format_map->{$macro};
my $format = { 'format' => $macro, 'text' => '', 'pre_style' =>
$complex_format->{'pre_style'} };
Index: examples/makeinfo.init
===================================================================
RCS file: /cvsroot/texi2html/texi2html/examples/makeinfo.init,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- examples/makeinfo.init 17 May 2009 15:35:16 -0000 1.28
+++ examples/makeinfo.init 22 May 2009 18:50:29 -0000 1.29
@@ -354,7 +354,6 @@
my $accesskey;
$accesskey = "accesskey=\"$menu_entry_index\"" if ($USE_ACCESSKEY and
($menu_entry_index < 10));
$entry = &$anchor ('', $href, $entry, $accesskey) if (defined($href));
- return $entry if ($SIMPLE_MENU);
# if ($state->{'preformatted'})
# {
# return '<li>' . main::do_preformatted($entry . $ending, $state);
@@ -374,7 +373,6 @@
{
my $text = shift;
my $state = shift;
- return $text if ($SIMPLE_MENU);
# if ($state->{'preformatted'})
# {
# return main::do_preformatted($text, $state) . '</td></tr>';
@@ -382,27 +380,4 @@
return "$text</li>\n";
}
-# a menu comment (between menu lines)
-# formats the container of a menu comment. A menu comment is any text
-# appearing between menu lines, either separated by an empty line from
-# the preceding menu entry, or a text beginning at the first character
-# of the line (text not at the very beginning of the line is considered to
-# be the continuation of a menu entry description text).
-#
-# The text itself is considered to be in a preformatted environment
-# with name 'menu-commment' and with style $MENU_PRE_STYLE.
-#
-# argument
-# text contained in the menu comment.
-sub makeinfo_like_menu_comment($)
-{
- my $text = shift;
- return $text if ($SIMPLE_MENU);
- if ($text =~ /\S/)
- {
- return "</ul>$text<ul>";
- }
- return '';
-}
-
1;
Index: test/run_test.sh
===================================================================
RCS file: /cvsroot/texi2html/texi2html/test/run_test.sh,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- test/run_test.sh 17 May 2009 20:10:32 -0000 1.13
+++ test/run_test.sh 22 May 2009 18:50:30 -0000 1.14
@@ -86,7 +86,10 @@
[ -d "$out_dir/$dir" ] && rm -rf "$out_dir/$dir"
else
do_info=no
- if echo "$remaining" | grep -qs -- '-init info.init'; then
+ if echo "$remaining" | grep -qs -- '-init info\.init'; then
+ do_info=yes
+ fi
+ if echo "$remaining" | grep -qs -- '--info'; then
do_info=yes
fi
if [ -d "$out_dir/$dir" ]; then
@@ -148,10 +151,10 @@
# -I $testdir/$srcdir_test/ is useful when file name is found using
# @setfilename
echo "$dir" >> $logfile
- echo "perl -w -x $testdir/$srcdir_test/../../texi2html.pl -conf-dir
$testdir/$srcdir_test/../../examples -conf-dir $testdir/$srcdir_test/ -test
--out $out_dir/$dir/ -I $testdir/$srcdir_test/ -I $testdir/$srcdir_test/../
-dump-texi $remaining $src_file 2>$out_dir/$dir/$basename.2" >> $logfile
- eval "perl -w -x $testdir/$srcdir_test/../../texi2html.pl -conf-dir
$testdir/$srcdir_test/../../examples -conf-dir $testdir/$srcdir_test/ -test
--out $out_dir/$dir/ -I $testdir/$srcdir_test/ -I $testdir/$srcdir_test/../
-dump-texi $remaining $src_file 2>$out_dir/$dir/$basename.2"
- echo "perl -w -x $testdir/$srcdir_test/../../texi2html.pl -conf-dir
$testdir/$srcdir_test/../../examples -conf-dir $testdir/$srcdir_test/ -test
--out $out_dir/$dir/ -I $testdir/$srcdir_test/ -I $testdir/$srcdir_test/../
--macro-expand=$out_dir/$dir/$basename.texi $remaining $src_file
2>>$out_dir/$dir/$basename.2" >> $logfile
- eval "perl -w -x $testdir/$srcdir_test/../../texi2html.pl -conf-dir
$testdir/$srcdir_test/../../examples -conf-dir $testdir/$srcdir_test/ -test
--out $out_dir/$dir/ -I $testdir/$srcdir_test/ -I $testdir/$srcdir_test/../
--macro-expand=$out_dir/$dir/$basename.texi $remaining $src_file
2>>$out_dir/$dir/$basename.2"
+ echo "perl -w -x $testdir/$srcdir_test/../../texi2html.pl -conf-dir
$testdir/$srcdir_test/../../examples -conf-dir
$testdir/$srcdir_test/../../formats -conf-dir $testdir/$srcdir_test/ -test
--out $out_dir/$dir/ -I $testdir/$srcdir_test/ -I $testdir/$srcdir_test/../
-dump-texi $remaining $src_file 2>$out_dir/$dir/$basename.2" >> $logfile
+ eval "perl -w -x $testdir/$srcdir_test/../../texi2html.pl -conf-dir
$testdir/$srcdir_test/../../examples -conf-dir
$testdir/$srcdir_test/../../formats -conf-dir $testdir/$srcdir_test/ -test
--out $out_dir/$dir/ -I $testdir/$srcdir_test/ -I $testdir/$srcdir_test/../
-dump-texi $remaining $src_file 2>$out_dir/$dir/$basename.2"
+ echo "perl -w -x $testdir/$srcdir_test/../../texi2html.pl -conf-dir
$testdir/$srcdir_test/../../examples -conf-dir
$testdir/$srcdir_test/../../formats -conf-dir $testdir/$srcdir_test/ -test
--out $out_dir/$dir/ -I $testdir/$srcdir_test/ -I $testdir/$srcdir_test/../
--macro-expand=$out_dir/$dir/$basename.texi $remaining $src_file
2>>$out_dir/$dir/$basename.2" >> $logfile
+ eval "perl -w -x $testdir/$srcdir_test/../../texi2html.pl -conf-dir
$testdir/$srcdir_test/../../examples -conf-dir
$testdir/$srcdir_test/../../formats -conf-dir $testdir/$srcdir_test/ -test
--out $out_dir/$dir/ -I $testdir/$srcdir_test/ -I $testdir/$srcdir_test/../
--macro-expand=$out_dir/$dir/$basename.texi $remaining $src_file
2>>$out_dir/$dir/$basename.2"
ret=$?
else
use_latex2html=no
@@ -171,14 +174,17 @@
elif echo "$remaining" | grep -qs -- '-init info.init'; then
do_info=yes
fi
+ if echo "$remaining" | grep -qs -- '--info'; then
+ do_info=yes
+ fi
one_test_done=yes
[ -d "$out_dir/$dir" ] && rm -rf "$out_dir/$dir"
mkdir "$out_dir/$dir"
echo "$dir" >> $logfile
echo >> $stdout_file
echo " ----> $dir" >> $stdout_file
- echo "perl -w -x $testdir/$srcdir_test/../../texi2html.pl -conf-dir
$testdir/$srcdir_test/../../examples -conf-dir $testdir/$srcdir_test/ -I
$testdir/$srcdir_test/ -I $testdir/$srcdir_test/../ -test --out $out_dir/$dir/
$remaining $src_file >> $stdout_file 2>$out_dir/$dir/$basename.2" >> $logfile
- eval "perl -w -x $testdir/$srcdir_test/../../texi2html.pl -conf-dir
$testdir/$srcdir_test/../../examples -conf-dir $testdir/$srcdir_test/ -I
$testdir/$srcdir_test/ -I $testdir/$srcdir_test/../ -test --out $out_dir/$dir/
$remaining $src_file >> $stdout_file 2>$out_dir/$dir/$basename.2"
+ echo "perl -w -x $testdir/$srcdir_test/../../texi2html.pl -conf-dir
$testdir/$srcdir_test/../../examples -conf-dir
$testdir/$srcdir_test/../../formats -conf-dir $testdir/$srcdir_test/ -I
$testdir/$srcdir_test/ -I $testdir/$srcdir_test/../ -test --out $out_dir/$dir/
$remaining $src_file >> $stdout_file 2>$out_dir/$dir/$basename.2" >> $logfile
+ eval "perl -w -x $testdir/$srcdir_test/../../texi2html.pl -conf-dir
$testdir/$srcdir_test/../../examples -conf-dir
$testdir/$srcdir_test/../../formats -conf-dir $testdir/$srcdir_test/ -I
$testdir/$srcdir_test/ -I $testdir/$srcdir_test/../ -test --out $out_dir/$dir/
$remaining $src_file >> $stdout_file 2>$out_dir/$dir/$basename.2"
ret=$?
rm -f $out_dir/$dir/*_l2h_images.log $out_dir/$dir/*_tex4ht_*.log \
$out_dir/$dir/*_tex4ht_*.idv $out_dir/$dir/*_tex4ht_*.dvi \
Index: formats/docbook.init
===================================================================
RCS file: formats/docbook.init
diff -N formats/docbook.init
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ formats/docbook.init 22 May 2009 18:50:29 -0000 1.1
@@ -0,0 +1,1579 @@
+#+##############################################################################
+#
+# docbook.init: convert to docbook
+#
+# Copyright (C) 2008 Patrice Dumas <address@hidden>
+#
+# 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 2 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, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA
+#
+#-##############################################################################
+
+use strict;
+
+my %docbook_complex_format;
+my $kept_footnote_function;
+my $docbook_in_footnote;
+my %docbook_sections;
+my %def_format_docbook;
+my %def_argument_types_docbook;
+
+my $docbook_pending_node_id;
+my @docbook_multitable_stack = ();
+my @docbook_table_stack = ();
+my @docbook_special_quotation;
+
+
+sub docbook_default_load()
+{
+
+html_default_load();
+
+$EXTENSION = "xml";
+$DOCTYPE = '<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
+ <!ENTITY tex "TeX">
+ <!ENTITY latex "LaTeX">
+]>';
+$USE_MENU_DIRECTIONS = 0;
+$USE_UP_FOR_ADJACENT_NODES = 0;
+$USE_NUMERIC_ENTITY = 0;
+$USE_SETFILENAME = 1;
address@hidden = ('docbook');
address@hidden = ('eps', 'gif', 'jpg', 'jpeg', 'pdf', 'png', 'svg', 'txt');
+$USE_ISO = 1;
+$INLINE_INSERTCOPYING = 1;
+
+$SHOW_MENU = 0;
+$SECTION_NAVIGATION = 0;
+
+push @command_handler_process, \&docbook_initialize_variables;
+
+$misc_command{'c'}->{'keep'} = 1;
+$misc_command{'comment'}->{'keep'} = 1;
+$misc_command{'settitle'}->{'keep'} = 1;
+
+delete $style_map{'sc'}->{'attribute'};
+$style_map{'code'}->{'attribute'} = 'literal';
+$style_map{'strong'}->{'attribute'} = 'emphasis role="bold"';
+$style_map{'kbd'}->{'attribute'} = 'userinput';
+$style_map{'w'}->{'end'} = '<!-- /@w -->';
+$style_map{'='}->{'function'} = \&docbook_macron;
+$style_map{'b'}->{'attribute'} = 'emphasis role="bold"';
+$style_map{'cite'}->{'attribute'} = 'citetitle';
+$style_map{'command'}->{'attribute'} = 'command';
+$style_map{'dfn'}->{'attribute'} = 'firstterm';
+$style_map{'emph'}->{'attribute'} = 'emphasis';
+$style_map{'env'}->{'attribute'} = 'envar';
+$style_map{'file'}->{'attribute'} = 'filename';
+$style_map{'i'}->{'attribute'} = 'wordasword';
+$style_map{'key'}->{'attribute'} = 'keycap';
+delete $style_map{'key'}->{'begin'};
+delete $style_map{'key'}->{'end'};
+$style_map{'option'}->{'attribute'} = 'option';
+$style_map{'t'}->{'attribute'} = 'literal';
+delete $style_map{'sansserif'}->{'attribute'};
+delete $style_map{'r'}->{'attribute'};
+$style_map{'indicateurl'}->{'attribute'} = 'wordasword';
+delete $style_map{'indicateurl'}->{'begin'};
+delete $style_map{'indicateurl'}->{'end'};
+$style_map{'var'}->{'attribute'} = 'replaceable';
+delete $style_map{'verb'}->{'attribute'};
+$style_map{'email'}->{'function'} = \&docbook_email;
+$style_map{'math'}->{'function'} = \&docbook_math;
+$style_map{'uref'}->{'function'} = \&docbook_uref;
+$style_map{'url'}->{'function'} = \&docbook_uref;
+$style_map{'titlefont'}->{'function'} = \&docbook_titlefont;
+$style_map{'samp'}->{'function'} = \&docbook_samp;
+delete $style_map{'samp'}->{'attribute'};
+#$style_map{'samp'}->{'attribute'} = 'literal';
+#$style_map{'samp'}->{'begin'} = '‘';
+#$style_map{'samp'}->{'end'} = '’';
+
+$kept_footnote_function = $style_map{'footnote'}->{'function'};
+$style_map{'footnote'}->{'function'} = \&docbook_footnote;
+
+#use Data::Dumper;
+foreach my $command (keys(%style_map))
+{
+ $style_map_pre{$command} = {};
+# $style_map_texi{$command} = {} if (!exists($style_map_texi{$command}));
+# $style_map_texi{$command}->{'args'} = $style_map{$command}->{'args'}
+# if (exists($style_map{$command}->{'args'}));
+ #print STDERR "COMMAND $command";
+
+ foreach my $key (keys(%{$style_map{$command}}))
+ {
+ $style_map_pre{$command}->{$key} = $style_map{$command}->{$key};
+ }
+}
+# print STDERR "". Data::Dumper->Dump([\%style_map_texi]);
+
+$style_map_pre{'b'}->{'attribute'} = 'lineannotation';
+$style_map_pre{'i'}->{'attribute'} = 'lineannotation';
+$style_map_pre{'r'}->{'attribute'} = 'lineannotation';
+
+$colon_command_punctuation_characters{'.'} = '.';
+$colon_command_punctuation_characters{':'} = ':';
+$colon_command_punctuation_characters{'?'} = '?';
+$colon_command_punctuation_characters{'!'} = '!';
+
+delete $stop_paragraph_command{'titlefont'};
+
+#Â FIXME
+#$no_paragraph_commands{'anchor'} = 0;
+
+# FIXME
+delete $special_accents{'ringaccent'};
+$special_accents{'ogonek'} = 'aeiuAEIU';
+
+foreach my $style (keys(%style_map))
+{
+ delete ($style_map{$style}->{'quote'});
+}
+
+$simple_map{' '} = ' ';
+# or '' ?
+$simple_map{'*'} = "\n";
+$simple_map{"\t"} = ' ';
+$simple_map{"\n"} = ' ';
+
+%simple_map_pre = %simple_map;
+
+# FIXME right?
+$things_map{'l'} = '/l';
+$things_map{'L'} = '/L';
+$things_map{'TeX'} = '&tex;';
+$things_map{'LaTeX'} = '&latex;';
+$things_map{'enddots'} = '….';
+$things_map{'minus'} = '−';
+# FIXME ∗
+$iso_symbols{'point'} = '-!-';
+# FIXME ≡
+$iso_symbols{'equiv'} = '==';
+delete $iso_symbols{"'"};
+delete $iso_symbols{'`'};
+$things_map{'quotedblbase'} = '„';
+$things_map{'quotesinglbase'} = '‚';
+
+%pre_map = %things_map;
+
+#delete $inter_item_commands{'cindex'};
+
+#$no_paragraph_commands{'cindex'} = 0;
+$no_paragraph_commands{'float'} = 0;
+
+%docbook_complex_format = (
+ 'example' => 'screen',
+ 'smallexample' => 'screen',
+ 'display' => 'literallayout',
+ 'smalldisplay' => 'literallayout',
+ 'lisp' => 'programlisting',
+ 'smalllisp' => 'programlisting',
+ 'format' => 'abstract',
+ 'smallformat' => 'screen'
+);
+
+%docbook_sections = (
+ 'top' => 'chapter',
+ 'chapter' => 'chapter',
+ 'unnumbered' => 'chapter',
+ 'centerchap' => 'chapter',
+ 'appendix' => 'appendix',
+ 'majorheading' => 'other',
+ 'chapheading' => 'other',
+ 'heading' => 'sect1',
+ 'subheading' => 'sect2',
+ 'subsubheading' => 'sect3',
+ 2 => 'sect1',
+ 3 => 'sect2',
+ 4 => 'sect3'
+);
+
+%def_format_docbook = (
+ 'deffn' => [ ['function', 'name'] ],
+ 'defvr' => [ ['varname', 'name'] ],
+ 'deftypefn' => [ [ 'returnvalue', 'type' ], ['function', 'name'] ],
+ 'deftypeop' => [ ['returnvalue', 'type'], ['methodname', 'name'] ],
+ 'deftypevr' => [ ['returnvalue', 'type'], ['varname', 'name'] ],
+ 'defcv' => [ ['classname', 'class'], ['property', 'name'] ],
+ 'deftypecv' => [ ['returnvalue', 'type'], ['property', 'name'] ],
+ 'defop' => [ ['classname', 'class'], ['methodname', 'name'] ],
+ 'deftp' => [ ['structname', 'name'] ]
+);
+
+%def_argument_types_docbook = (
+ 'param' => 'replaceable',
+ 'paramtype' => 'type',
+ 'delimiter' => ''
+);
+
address@hidden = ('note', 'caution', 'important', 'tip', 'warning');
+
+$region_formats_kept{'copying'} = 1;
+
+$format_map{'copying'} = 'copying';
+
+delete $format_map{'enumerate'};
+foreach my $table ('table', 'ftable', 'vtable')
+{
+ #$format_map{$table} = 'table';
+ delete $format_map{$table};
+}
+
+delete $iso_symbols{'`'};
+$print_Top = \&docbook_print_Top;
+$print_Top_footer = \&docbook_print_Top_footer;
+$print_page_head = \&docbook_print_page_head;
+#$print_navigation = \&docbook_noop;
+$print_foot_navigation = \&docbook_noop;
+$toc_body = \&docbook_noop;
+$about_body = \&docbook_noop;
+$print_page_foot = \&docbook_print_page_foot;
+$end_section = \&docbook_end_section;
+$one_section = \&docbook_one_section;
+
+$heading = \&docbook_heading;
+#$heading_texi = \&docbook_heading_texi;
+$paragraph = \&docbook_paragraph;
+$preformatted = \&docbook_preformatted;
+$misc_element_label = \&docbook_noop;
+$element_label = \&docbook_element_label;
+$anchor_label = \&docbook_anchor_label;
+$index_entry_label = \&docbook_index_entry_label;
+$index_entry_command = \&docbook_index_entry_command;
+$listoffloats = \&docbook_noop;
+$acronym_like = \&docbook_acronym_like;
+$foot_line_and_ref = \&docbook_foot_line_and_ref;
+$image = \&docbook_image;
+$image_files = \&docbook_image_files;
+$sp = \&docbook_sp;
+$table_list = \&docbook_table_list;
+$row = \&docbook_row;
+$cell = \&docbook_cell;
+$list_item = \&docbook_list_item;
+$format_list_item_texi = \&docbook_format_list_item_texi;
+$unknown = \&docbook_misc_commands;
+$begin_format_texi = \&docbook_begin_format_texi;
+$def_line = \&docbook_def_line;
+$def = \&docbook_def;
+$def_item = \&docbook_def_item;
+$printindex = \&docbook_printindex;
+$index_summary = \&docbook_index_summary;
+$external_ref = \&docbook_external_ref;
+$internal_ref = \&docbook_internal_ref;
+$table_item = \&docbook_table_item;
+$table_line = \&docbook_table_line;
+$float = \&docbook_float;
+#$caption_shortcaption = \&docbook_caption_shortcaption;
+#$caption_shortcaption_command = \&docbook_caption_shortcaption_command;
+$normal_text = \&docbook_normal_text;
+#$paragraph_style_command = \&docbook_paragraph_style_command;
+$raw = \&docbook_raw;
+$cartouche = \&docbook_cartouche;
+
+$complex_format = \&docbook_complex_format;
+$format = \&docbook_format;
+$quotation = \&docbook_quotation;
+$quotation_prepend_text = \&docbook_quotation_prepend_text;
+$style = \&docbook_style;
+$insertcopying = \&docbook_insertcopying;
+
+}
+
+sub docbook_footnote($$$$$)
+{
+ $docbook_in_footnote = 1;
+ my $result = &$kept_footnote_function(@_);
+ $docbook_in_footnote = 0;
+ return $result;
+}
+
+sub docbook_macron($$)
+{
+ my $accent = shift;
+ my $args = shift;
+ return $args->[0] . "¯";
+}
+
+sub docbook_samp($$)
+{
+ shift;
+ my $args = shift;
+ return "‘<literal>$args->[0]</literal>’";
+}
+
+sub docbook_email($$)
+{
+ my $command = shift;
+ my $args = shift;
+ my $mail = shift @$args;
+ my $text = shift @$args;
+ $mail = main::normalise_space($mail);
+ if (defined($text) and $text =~ /\S/)
+ {
+ return docbook_add_id('ulink').'
url="mailto:'.main::normalise_space($mail).'">'.$text.'</ulink>';
+ }
+ return docbook_add_id('email').">$mail</email>";
+}
+
+sub docbook_uref($$)
+{
+ shift;
+ my $args = shift;
+ my $url = shift @$args;
+ my $text = shift @$args;
+ my $replacement = shift @$args;
+ $url = main::normalise_space($url);
+ $text = '' if (!defined($text));
+ $replacement = '' if (!defined($replacement));
+ $replacement = $text if ($replacement eq '');
+ $replacement = $url if ($replacement eq '');
+ $replacement = main::normalise_space($replacement);
+
+ return docbook_add_id('ulink')." url=\"$url\">$replacement</ulink>";
+}
+
+# FIXME
+sub docbook_titlefont($$)
+{
+ shift;
+ my $args = shift;
+ return "$args->[0]";
+}
+
+sub docbook_math($$)
+{
+ shift;
+ my $args = shift;
+ my $text = shift @$args;
+ $text =~ s/[{}]//g;
+ return $text;
+}
+
+
+sub docbook_print_page_head($)
+{
+ my $fh = shift;
+ my $language = get_conf('documentlanguage');
+ print $fh <<EOT;
+<?xml version="1.0"?>
+$DOCTYPE
+<book id="$Texi2HTML::THISDOC{file_base_name}.$EXTENSION" lang="$language">
+EOT
+}
+
+sub docbook_print_page_foot($)
+{
+ my $fh = shift;
+ print $fh <<EOT;
+</book><!-- Keep this comment at the end of the file
+Local variables:
+mode: sgml
+sgml-indent-step:1
+sgml-indent-data:nil
+End:
+-->
+EOT
+}
+
+sub docbook_print_Top($$$)
+{
+ my $fh = shift;
+ my $has_top_heading = shift;
+ my $element = shift;
+ #print $fh "".docbook_heading($element);
+ main::print_lines($fh, $Texi2HTML::THIS_SECTION);
+}
+
+sub docbook_element_tag($)
+{
+ my $element = shift;
+#print STDERR "$element->{'texi'}, $element->{'tag_level'},
$element->{'level'}\n";
+ return $docbook_sections{$element->{'tag_level'}} if
(exists($docbook_sections{$element->{'tag_level'}}));
+ return $docbook_sections{$element->{'level'}} if
(exists($docbook_sections{$element->{'level'}}));
+}
+
+sub docbook_node_id($)
+{
+ my $node_texi = shift;
+ my $node = main::remove_texi($node_texi);
+ $node =~ s/[\s\"]/-/g;
+ return &$protect_text($node);
+}
+
+sub docbook_initialize_variables()
+{
+ $docbook_pending_node_id = undef;
+ @docbook_multitable_stack = ();
+ @docbook_table_stack = ();
+}
+
+sub docbook_add_id($)
+{
+ my $element = shift;
+ my $result = "<$element";
+ if (defined($docbook_pending_node_id) and (!$docbook_in_footnote or
$element eq 'footnote'))
+ {
+ $result .= " id=\"$docbook_pending_node_id\"";
+ $docbook_pending_node_id = undef;
+ }
+ return $result;
+}
+
+sub docbook_heading($$$$$)
+{
+ my $element = shift;
+ my $command = shift;
+ my $texi_line = shift;
+ my $line = shift;
+ my $in_preformatted = shift;
+
+ if (defined($command) and $command =~ /heading/)
+ {
+ my $text = '';
+ if (defined($line))
+ {
+ $text = $line;
+ # this isn't done in main program in that case...
+ chomp ($text);
+ $text =~ s/^\s*//;
+ }
+ return docbook_add_id('bridgehead')."
renderas=\"$docbook_sections{$command}\">$text</bridgehead>\n";
+ }
+
+# my $node_element = $element;
+# if (defined($element->{'node_ref'}))
+# {
+# $node_element = $element->{'node_ref'};
+# }
+
+ my $result = '';
+
+# FIXME verify xreflabel
+ if (!$element->{'node'})
+ {
+ my $id_text = '';
+ if ($element->{'with_node'})
+ {
+ my $id = $element->{'with_node'}->{'text_nonumber'};
+ $id =~ s/ /-/g;
+ $id_text = " id=\"$id\"";
+ }
+ my $title = $element->{'text_nonumber'};
+ my $label = '';
+ my $xreflabel = '';
+ if ($element->{'number'})
+ {
+ my $label_nr = $element->{'number'};
+ $label_nr =~ s/\.$//;
+ $label = $label_nr;
+ }
+ else
+ {
+ my $xreftitle = $title;
+ $xreflabel = " xreflabel=\"$xreftitle\"";
+ }
+ $result .= '<' . docbook_element_tag($element) . "
label=\"${label}\"${xreflabel}${id_text}>\n<title>$title</title>\n";
+ }
+ return $result;
+}
+
+sub docbook_element_label($$$$)
+{
+ my $id = shift;
+ my $element = shift;
+ my $command = shift;
+ my $line = shift;
+
+ if ($element->{'node'} and !$element->{'with_section'})
+ {
+ $docbook_pending_node_id = docbook_node_id($element->{'texi'});
+ }
+ elsif ($command !~ /heading/)
+ {
+ $docbook_pending_node_id = undef;
+ }
+ return '';
+}
+
+sub docbook_paragraph($$$$$$$$$$$$)
+{
+ my $text = shift;
+ my $align = shift;
+ my $indent = shift;
+ my $paragraph_command = shift;
+ my $paragraph_command_formatted = shift;
+ my $paragraph_number = shift;
+ my $format = shift;
+ my $item_nr = shift;
+ my $enumerate_style = shift;
+ my $number = shift;
+ my $command_stack_at_end = shift;
+ my $command_stack_at_begin = shift;
+
+ foreach my $style(t2h_collect_styles($command_stack_at_begin))
+ {
+#print STDERR "PARA BEGIN STYLE $style\n";
+ $text = t2h_begin_style($style, $text);
+ }
+ foreach my $style(t2h_collect_styles($command_stack_at_end))
+ {
+#print STDERR "PARA END STYLE $style\n";
+ $text = t2h_end_style($style, $text);
+ }
+ if (defined($paragraph_number) and defined($$paragraph_number))
+ {
+ $$paragraph_number++;
+ }
+
+ # no para in multitables, caption and shortcaptions.
+ my $top_stack = '';
+ $top_stack = $command_stack_at_begin->[-1] if (scalar
(@$command_stack_at_begin));
+ return $text if ($top_stack eq 'multitable' or $top_stack eq
'shortcaption' or $top_stack eq 'caption' or $top_stack eq
'documentdescription');
+
+ if ($text =~ /\S/)
+ {
+ #return docbook_add_id('para').">$text</para>";
+ return "<para>$text</para>";
+ }
+ return $text;
+}
+
+
+sub docbook_def_line($$$$$$$$$$$$$$$)
+{
+ my $category_prepared = shift;
+ my $name = shift;
+ my $type = shift;
+ my $arguments = shift;
+ my $index_label = shift;
+ my $arguments_array = shift;
+ my $arguments_type_array = shift;
+ my $unformatted_arguments_array = shift;
+ my $command = shift;
+ my $class_name = shift;
+ my $category = shift;
+ my $class = shift;
+ my $style = shift;
+ my $original_command = shift;
+
+ my %unformatted_arguments = ();
+
+ my @unformatted_args = @$unformatted_arguments_array;
+ foreach my $type (@$arguments_type_array)
+ {
+ my $unformatted_arg = shift @unformatted_args;
+ $unformatted_arguments{$type} = $unformatted_arg;
+ }
+ # FIXME unformatted!
+ my $result = "<synopsis
role=\"$unformatted_arguments{'category'}\"><indexterm role=\""
+
.$main::index_prefix_to_name{$style}."\"><primary>$class_name</primary></indexterm>";
+
+ my %arguments = ( 'prepared_category' => $category_prepared,
+ 'category' => $category,
+ 'name' => $name,
+ 'type' => $type,
+ 'class' => $class
+ );
+ foreach my $type (keys(%arguments))
+ {
+ $arguments{$type} = '' if (!defined($arguments{$type}));
+ }
+
+ foreach my $mandatory_arg (@{$def_format_docbook{$command}})
+ {
+ my $elem = $mandatory_arg->[0];
+ #if ($elem eq 'returnvalue' and
$unformatted_arguments{$mandatory_arg->[1]} =~ /address@hidden/)
+ if ($elem eq 'returnvalue' and
$unformatted_arguments{$mandatory_arg->[1]} =~ /address@hidden/)
+ {
+ # FIXME unformatted
+ my $arg_without_at_command =
$unformatted_arguments{$mandatory_arg->[1]};
+ #$arg_without_at_command =~ s/address@hidden//;
+ #$arg_without_at_command =~ s/\}\s*$//;
+ while ($arg_without_at_command =~ /address@hidden([^\{\}]*)\}/)
+ {
+ $arg_without_at_command =~ s/address@hidden([^\{\}]*)\}/$1/;
+ }
+ $result .= "<$elem>$arg_without_at_command</$elem>";
+ }
+ else
+ {
+ $result .= "<$elem>$arguments{$mandatory_arg->[1]}</$elem>";
+ }
+ }
+
+ my @types = @$arguments_type_array;
+ @unformatted_args = @$unformatted_arguments_array;
+ foreach my $arg (@$arguments_array)
+ {
+ my $type = shift @types;
+ my $unformatted = shift @unformatted_args;
+ if (exists ($def_argument_types_docbook{$type}))
+ {
+ if ($def_argument_types_docbook{$type} and
+ ($type eq 'paramtype' or ($unformatted !~ /address@hidden/)))
+ {
+ $result .=
"<$def_argument_types_docbook{$type}>$arg</$def_argument_types_docbook{$type}>";
+ }
+ else
+ {
+ $result .= $arg;
+ }
+ }
+ }
+
+ $result .= "</synopsis>\n";
+ return $result;
+}
+
+# FIXME
+# @deffn
+# @c comment
+# @end deffn
+# leads to the creation of a <definitionitem> with a comment within,
+# while there should be no definitionitem
+sub docbook_def_item($)
+{
+ my $text = shift;
+ my $only_inter_item_commands = shift;
+
+ if ($text =~ /\S/)
+ {
+ return '<blockquote>' . $text . '</blockquote>' unless
$only_inter_item_commands;
+ return $text;
+ }
+ return '';
+}
+
+sub docbook_def($)
+{
+ my $text = shift;
+ return docbook_add_id('informalfigure').'>'.$text.'</informalfigure>';
+}
+
+sub docbook_preformatted($$$$$$$$$$$$)
+{
+ my $text = shift;
+ my $pre_style = shift;
+ my $class = shift;
+ my $leading_command = shift;
+ my $leading_command_formatted = shift;
+ my $preformatted_number = shift;
+ my $format = shift;
+ my $item_nr = shift;
+ my $enumerate_style = shift;
+ my $number = shift;
+ my $command_stack_at_end = shift;
+ my $command_stack_at_begin = shift;
+
+ return $text;
+}
+
+sub docbook_misc_commands($$$$$)
+{
+ my $macro = shift;
+ my $line = shift;
+ my $pass = shift;
+ my $stack = shift;
+ my $state = shift;
+#print STDERR "$macro $pass $line";
+ return ($line, 0, undef, undef) unless ($pass == 2);
+ return ($line, 0, undef, undef) unless defined($misc_command{$macro});
+
+ my ($result_line, $text, $args) = &$preserve_misc_command ($line, $macro);
+#print STDERR "$macro $pass $line";
+#print STDERR "ARGS @$args\n" if defined ($args);
+ my $result_text = undef;
+ if ($macro eq 'c' or $macro eq 'comment' and scalar(@$args))
+ {
+ my $comment_line = $args->[0];
+ chomp ($comment_line);
+ # makeinfo remove all the leading spaces
+ $comment_line =~ s/^\s//;
+ $result_text = &$comment ($comment_line);
+ }
+ elsif ($macro eq 'settitle')
+ {
+ # FIXME to be formatted?
+ my $arg = $args->[0];
+ $arg =~ s/^\s*//;
+ chomp($arg);
+ $result_text = "<title>$arg</title>\n";
+ }
+ else
+ {
+ return ($line, 0, undef, undef);
+ }
+ return ($result_line, 1, $result_text, undef);
+}
+
+sub docbook_foot_line_and_ref($$$$$$$)
+{
+ my $number_in_doc = shift;
+ my $number_in_page = shift;
+ my $footnote_id = shift;
+ my $place_id = shift;
+ my $document_file = shift;
+ my $footnote_file = shift;
+ my $lines = shift;
+ my $state = shift;
+
+ my $result = docbook_add_id('footnote').'>';
+ foreach my $line (@$lines)
+ {
+ $result .= $line;
+ }
+ return ([], $result . '</footnote>');
+}
+
+sub docbook_any_ref($$$)
+{
+ my $type = shift;
+ my $args = shift;
+ my $unformatted_args = shift;
+
+ if ($type eq 'inforef')
+ {
+ my $node_file = "($args->[2])$args->[0]";
+ if ($args->[1] ne '')
+ {
+ return "*note $args->[1]: $node_file";
+ }
+ else
+ {
+ return "*note ${node_file}::";
+ }
+ }
+ else
+ {
+ if (($args->[3] ne '') or ($args->[4] ne ''))
+ {
+ return '' if ($args->[4] eq '');
+ my $section_name = $args->[2];
+ $section_name = $args->[0] if ($section_name eq '');
+ if ($type eq 'ref')
+ {
+ return &$I('section address@hidden'@asis{}\' in
@cite{%{book}}', { 'section_name' => $section_name, 'book' => $args->[4]
},{'duplicate'=>1});
+ }
+ elsif ($type eq 'xref')
+ {
+ return &$I('See section address@hidden'@asis{}\' in
@cite{%{book}}', { 'section_name' => $section_name, 'book' => $args->[4]
},{'duplicate'=>1});
+ }
+ elsif ($type eq 'pxref')
+ {
+ return &$I('see section address@hidden'@asis{}\' in
@cite{%{book}}', { 'section_name' => $section_name, 'book' => $args->[4]
},{'duplicate'=>1});
+ }
+ }
+ my $link = docbook_node_id($unformatted_args->[0]);
+ my $title = $args->[2];
+ $title = $args->[1] if ($title eq '');
+ if ($title eq '')
+ {
+ if ($type eq 'ref')
+ {
+ return &$I('%{ref}', {'ref' => docbook_add_id('xref')."
linkend=\"$link\"></xref>"});
+ }
+ elsif ($type eq 'pxref')
+ {
+ return &$I('see %{ref}', {'ref' => docbook_add_id('xref')."
linkend=\"$link\"></xref>"});
+ }
+ elsif ($type eq 'xref')
+ {
+ return &$I('See %{ref}', {'ref' => docbook_add_id('xref')."
linkend=\"$link\"></xref>"});
+ }
+ }
+ else
+ {
+ if ($type eq 'ref')
+ {
+ return &$I('%{title_ref}', {'title_ref' =>
docbook_add_id('link')." linkend=\"$link\">$title</link>"});
+ }
+ elsif ($type eq 'pxref')
+ {
+ return &$I('see %{title_ref}', {'title_ref' =>
docbook_add_id('link')." linkend=\"$link\">$title</link>"},{'duplicate'=>1});
+ }
+ elsif ($type eq 'xref')
+ {
+ return &$I('See %{title_ref}', {'title_ref' =>
docbook_add_id('link')." linkend=\"$link\">$title</link>"},{'duplicate'=>1});
+ }
+ }
+ }
+}
+
+sub docbook_external_ref($$$$$$)
+{
+ my $type = shift;
+ my $section = shift;
+ my $book = shift;
+ my $file_node = shift;
+ my $href = shift;
+ my $cross_ref = shift;
+ my $args_texi = shift;
+ my $formatted_args = shift;
+
+ return docbook_any_ref ($type, $formatted_args, $args_texi);
+}
+
+sub docbook_internal_ref($$$$$)
+{
+ my $type = shift;
+ my $href = shift;
+ my $short_name = shift;
+ my $name = shift;
+ my $is_section = shift;
+ my $args_texi = shift;
+ my $formatted_args = shift;
+
+ return docbook_any_ref ($type, $formatted_args, $args_texi );
+}
+
+sub docbook_index_entry_command($$$$$)
+{
+ my $command = shift;
+ my $index_name = shift;
+ my $label = shift;
+ my $entry_texi = shift;
+ my $entry_formatted = shift;
+
+ return $label if (defined($label) and $label ne '');
+ return
docbook_index_entry_label('','','',$main::index_prefix_to_name{$index_name},
'', '', $entry_formatted);
+}
+
+sub docbook_index_entry_label($$$$$)
+{
+ my $identifier = shift;
+ my $preformatted = shift;
+ my $entry = shift;
+ my $index_name = shift;
+ my $index_command = shift;
+ my $texi_entry = shift;
+ my $formatted_entry = shift;
+
+ return "<indexterm
role=\"${index_name}\"><primary>${formatted_entry}</primary></indexterm>";
+}
+
+sub docbook_footing($)
+{
+ my $element = shift;
+
+ my $result = '';
+
+ return '' if ($element->{'node'});
+ return '</'.docbook_element_tag($element).">\n" if ($element->{'level'} ==
0);
+ return '' if ($element->{'child'});
+ $result .= '</'.docbook_element_tag($element).">\n";
+
+ return $result if ($element->{'sectionnext'} or $element->{'level'} == 1);
+ my $current = $element;
+ while ($current->{'level'} != 1 and $current->{'sectionup'} and
(!$current->{'sectionup'}->{'sectionnext'} or
$current->{'sectionup'}->{'level'} == 1))
+ {
+ $current = $current->{'sectionup'};
+ $result .= '</'.docbook_element_tag($current).">\n";
+ }
+ return $result;
+}
+
+sub docbook_end_section($$$)
+{
+ my $fh = shift;
+ my $end_foot_navigation = shift;
+ my $element = shift;
+ print $fh "". docbook_footing($element);
+}
+
+sub docbook_print_Top_footer($$)
+{
+ my $fh = shift;
+ my $end_page = shift;
+ my $element = shift;
+
+ print $fh "". docbook_footing($element);
+}
+
+sub docbook_one_section($$)
+{
+ my $fh = shift;
+ my $element = shift;
+ main::print_lines($fh);
+ print $fh "". docbook_footing($element);
+ &$print_foot_navigation($fh);
+ &$print_page_foot($fh);
+}
+
+sub docbook_insertcopying($)
+{
+ my $text = shift;
+ my $comment = shift;
+ my $simple_text = shift;
+
+ return $text;
+}
+
+sub docbook_acronym_like($$$$$$)
+{
+ my $command = shift;
+ my $acronym_texi = shift;
+ my $acronym_text = shift;
+ my $with_explanation = shift;
+ my $explanation_lines = shift;
+ my $explanation_text = shift;
+ my $explanation_simply_formatted = shift;
+
+ $command = 'abbrev' if ($command eq 'abbr');
+ my $result = docbook_add_id($command).">$acronym_text</${command}>";
+ if ($with_explanation)
+ {
+ $result .= " ($explanation_text)";
+ }
+ return $result;
+}
+
+
+sub docbook_image_files($$$$)
+{
+ my $base = shift;
+ my $extension = shift;
+ my $texi_base = shift;
+ my $texi_extension = shift;
+ my @files = ();
+ return @files if (!defined($base) or ($base eq ''));
+# FIXME should look at extension argument? makeinfo doesn't
+# push @files,"$base.$extension" if (defined($extension) and ($extension ne
''));
+ foreach my $ext (@IMAGE_EXTENSIONS)
+ {
+ push @files, ["$base.$ext", "$texi_base.$ext"];
+ }
+ return @files;
+}
+
+
+sub docbook_image($$$$$$$$$$$$$$$$;$)
+{
+ my $file = shift;
+ my $base = shift;
+ my $preformatted = shift;
+ my $file_name = shift;
+ my $alt = shift;
+ my $width = shift;
+ my $height = shift;
+ my $raw_alt = shift;
+ my $extension = shift;
+ my $working_dir = shift;
+ my $file_path = shift;
+ my $in_paragraph = shift;
+ my $file_locations = shift;
+ my $base_simple_format = shift;
+ my $extension_simple_format = shift;
+ my $file_name_simple_format = shift;
+ my $line_nr = shift;
+
+# if (!defined($file_path) or $file_path eq '' or $file_path =~ /\.txt$/)
+# {
+# if (defined($extension) and $extension ne '')
+# {
+# $file = "$base.$extension";
+# }
+# else
+# {
+# $file = "$base.jpg";
+# $extension = 'jpg';
+# }
+# main::echo_warn ("no image file for $base, (using $file)");
+# }
+ my $txt_path;
+ my @files = ();
+ my @extensions = @IMAGE_EXTENSIONS;
+ foreach my $file_location (@$file_locations)
+ {
+ my ($file_located, $path, $file_simple_format) = @$file_location;
+ my $extension = shift @extensions;
+ if (defined($path))
+ {
+ if ($extension eq 'txt' and !defined($txt_path))
+ {
+ $txt_path = $path;
+ }
+ else
+ {
+ push @files, [$file_located, uc($extension),
$file_simple_format];
+ }
+ }
+ }
+ push @files, ["$base.jpg", 'JPG', "$base_simple_format.jpg" ] unless
(@files);
+
+ my $begin = docbook_add_id('inlinemediaobject').'>';
+ my $end = '</inlinemediaobject>';
+ if ($preformatted or !$in_paragraph)
+ {
+ $begin = docbook_add_id('informalfigure').'><mediaobject>';
+ $end = '</mediaobject></informalfigure>';
+ }
+ my $result = $begin;
+ foreach my $file_spec (@files)
+ {
+ $result .= "<imageobject><imagedata fileref=\"$file_spec->[2]\"
format=\"$file_spec->[1]\"></imagedata></imageobject>";
+ }
+ if (defined($txt_path))
+ {
+ if (open(TXT, "<$txt_path"))
+ {
+ if (defined($Texi2HTML::THISDOC{'IN_ENCODING'}) and $USE_UNICODE)
+ {
+ binmode(TXT, ":encoding($Texi2HTML::THISDOC{'IN_ENCODING'})");
+ }
+ $result.="<textobject><literallayout>";
+ while (my $img_txt = <TXT>)
+ {
+ $result .= $img_txt;
+ }
+ $result .= '</literallayout></textobject>';
+ close(TXT);
+ }
+ else
+ {
+ main::echo_warn ("address@hidden file `$txt_path' unreadable: $!",
$line_nr);
+ }
+ }
+ else
+ {
+ main::echo_warn ("Cannot find address@hidden file `$base.txt'",
$line_nr);
+ }
+
+ return "$result$end";
+}
+
+sub docbook_format_list_item_texi($$$$)
+{
+ my $format = shift;
+ my $line = shift;
+ my $prepended = shift;
+ my $command = shift;
+
+ my $result_line = undef;
+
+ if (defined($command) and $command ne '' and !exists
$special_list_commands{$format}->{$command} and $format ne 'itemize')
+ {
+ address@hidden
+ $line =~ s/^\s*//;
+ $line =~ s/\s*$//;
+ if (exists ($style_map{$command}))
+ {
+ $result_line = "address@hidden";
+ }
+ elsif (exists ($things_map{$command}))
+ {
+ $result_line = "address@hidden $line\n";
+ }
+ else
+ {
+ $result_line = "address@hidden $line\n";
+ }
+ }
+
+ return ($result_line, 0);
+}
+
+
+# row in multitable
+sub docbook_row($$;$$)
+{
+ my $text = shift;
+ my $macro = shift;
+ my $columnfractions = shift;
+ my $prototype_row = shift;
+ my $prototype_lengths = shift;
+ my $column_number = shift;
+
+ my $result = '';
+ if ($macro eq 'headitem')
+ {
+ if ($docbook_multitable_stack[-1] != 0)
+ {
+ $result .= "<thead>";
+ $result = "</tbody>" . $result if ($docbook_multitable_stack[-1]
== 1);
+ $docbook_multitable_stack[-1] = 0;
+ }
+ }
+ elsif ($docbook_multitable_stack[-1] != 1)
+ {
+ $result .= "<tbody>";
+ $result = "</thead>" . $result if ($docbook_multitable_stack[-1] ==
0);
+ $docbook_multitable_stack[-1] = 1;
+ }
+ $result .= "<row>$text</row>";
+
+ return $result;
+}
+
+# cell in multitable
+sub docbook_cell($$;$$)
+{
+ my $text = shift;
+ my $row_macro = shift;
+ my $columnfractions = shift;
+ my $prototype_row = shift;
+ my $prototype_lengths = shift;
+ my $column_number = shift;
+
+ return "<entry>" . $text . '</entry>';
+}
+
+# if varlistentry_state is > 0 it means that a varlistentry is opened.
+# if varlistentry_state is == 2 it means that we are in a succession
+# of term
+# if varlistentry_state is == 1 it means that we are in the line
+# Having a listitem in a varlistentry is a must, so an empty
+# listitem is added if a varlistentry is closed and varlistentry_state == 2
+#
+# varlistentry acceps only term and listitem, so inter_item_commands
+# are put in the next term, or, if at the end of the table in a last
+# listitem
+sub docbook_table_item($$$$$$)
+{
+ my $text = shift;
+ my $index_label = shift;
+ my $format = shift;
+ my $command = shift;
+# my $formatted_command = shift;
+ my $style_stack = shift;
+# my $text_formatted = shift;
+# my $text_formatted_leading_spaces = shift;
+# my $text_formatted_trailing_spaces = shift;
+ my $item_cmd = shift;
+
+# $formatted_command = '' if (!defined($formatted_command));
+
+# if (defined($text_formatted))
+# {
+# $text_item = $text_formatted_leading_spaces . $text_formatted
.$text_formatted_trailing_spaces;
+# }
+# else
+# {
+# $text_item = $text;
+# }
+
+ my $result = '';
+ my $prepended = '';
+ if (defined($docbook_table_stack[-1]->{'inter_item'}))
+ {
+ #$formatted_command = $docbook_table_stack[-1]->{'inter_item'} .
$formatted_command;
+ $prepended = $docbook_table_stack[-1]->{'inter_item'};
+ delete $docbook_table_stack[-1]->{'inter_item'};
+ }
+ if ($item_cmd eq 'item')
+ {
+ if ($docbook_table_stack[-1]->{'varlistentry_state'} == 2)
+ {
+ $result .= "<listitem><para><!-- empty table line
--></para></listitem>";
+ }
+ if ($docbook_table_stack[-1]->{'varlistentry_state'} >= 1)
+ {
+ $result .= '</varlistentry>';
+ }
+ $docbook_table_stack[-1]->{'varlistentry_state'} = 2;
+ $result .= '<varlistentry>';
+ }
+ $result .= '<term>';
+ $result .= $prepended . $text ."</term>\n";
+ return $result;
+}
+
+sub docbook_table_line($$$)
+{
+ my $text = shift;
+ my $only_inter_item_commands = shift;
+ my $before_items = shift;
+
+ $only_inter_item_commands = '' if (!defined($only_inter_item_commands));
+
+#print STDERR
+
+ if ($text =~ /\S/)
+ {
+ if ($before_items)
+ {
+ return $text;
+ }
+
+ if ($only_inter_item_commands)
+ {
+ $docbook_table_stack[-1]->{'inter_item'} = $text;
+ return '';
+ }
+ else
+ {
+ $docbook_table_stack[-1]->{'varlistentry_state'} = 1;
+ return "<listitem>$text</listitem>";
+ }
+ #return $text;
+ }
+ else
+ {
+ return '';
+ }
+}
+
+sub docbook_list_item($$$$$$$$$)
+{
+ my $text = shift;
+ my $format = shift;
+ my $command = shift;
+ my $formatted_command = shift;
+ my $item_nr = shift;
+ my $enumerate_style = shift;
+ my $number = shift;
+ my $prepended = shift;
+ my $prepended_formatted = shift;
+ my $only_inter_item_commands = shift;
+ my $before_items = shift;
+
+ $only_inter_item_commands = '' if (!defined($only_inter_item_commands));
+
+#my $prep_t = 'UNDEF'; $prep_t = $prepended if (defined($prepended));
+#$item_nr = 0 if (!defined($item_nr));
+#print STDERR " $item_nr --> $prep_t|${text}!!!!!\n";
+ #return $text if ($only_inter_item_commands and $before_items);
+ return $text if ($before_items);
+ return '<listitem>' . $text . "</listitem>\n";
+}
+
+sub docbook_table_list($$$$$$$$$)
+{
+ my $format_command = shift;
+ my $text = shift;
+ my $command = shift;
+ my $formatted_command = shift;
+# enumerate
+ my $item_nr = shift;
+ my $enumerate_style = shift;
+# itemize
+ my $prepended = shift;
+ my $prepended_formatted = shift;
+# multitable
+ my $columnfractions = shift;
+ my $prototype_row = shift;
+ my $prototype_lengths = shift;
+ my $number = shift;
+
+ my $result = "<$format_command>";
+ if ($format_command eq 'itemize')
+ {
+ my $itemfunction;
+ #$prepended_formatted =~ s/^\s*// if (defined($prepended_formatted));
+ $prepended =~ s/^\s*// if (defined($prepended));
+ #if (defined($formatted_command) and $formatted_command ne '')
+ if (defined($command) and $command ne '')
+ {
+ #$itemfunction = $formatted_command;
+ $itemfunction = $command;
+ #$itemfunction .= " $prepended_formatted" if
(defined($prepended_formatted) and $prepended_formatted ne '');
+ $itemfunction .= " $prepended" if (defined($prepended) and
$prepended ne '');
+ }
+ #elsif (defined($prepended_formatted))
+ elsif (defined($prepended))
+ {
+ #$itemfunction = $prepended_formatted;
+ $itemfunction = $prepended;
+ }
+ my $mark = '';
+ $mark = " mark=\"$itemfunction\"" if (defined($itemfunction) and
$itemfunction ne '');
+ return docbook_add_id('itemizedlist')."${mark}>$text</itemizedlist>";
+ }
+ elsif ($format_command eq 'enumerate')
+ {
+ my $numeration='arabic';
+ if (defined($enumerate_style) and $enumerate_style ne '')
+ {
+ if ($enumerate_style =~ /^[A-Z]/)
+ {
+ $numeration = 'upperalpha';
+ }
+ elsif ($enumerate_style =~ /^[a-z]/)
+ {
+ $numeration = 'loweralpha';
+ }
+ }
+ return docbook_add_id('orderedlist') ."
numeration=\"$numeration\">$text</orderedlist>";
+ }
+ elsif ($format_command eq 'multitable')
+ {
+ my $result = docbook_add_id('informaltable').'><tgroup
cols="'.$number.'">';
+ my $fractions;
+ my $multiply = 1;
+ if (defined($columnfractions) and (ref($columnfractions) eq 'ARRAY')
+ and scalar(@$columnfractions))
+ {
+ $fractions = [ @$columnfractions ];
+ $multiply = 100;
+ }
+ elsif (defined($prototype_lengths) and (ref($prototype_lengths) eq
'ARRAY')
+ and scalar(@$prototype_lengths))
+ {
+ $fractions = [ @$prototype_lengths ];
+ }
+
+ if (defined ($fractions))
+ {
+ foreach my $fraction (@$fractions)
+ {
+ $result .= '<colspec
colwidth="'.($fraction*$multiply).'*"></colspec>';
+ }
+ }
+ $text .= "</tbody>" if ($docbook_multitable_stack[-1] == 1);
+ $text .= "</thead>" if ($docbook_multitable_stack[-1] == 0);
+ pop @docbook_multitable_stack;
+ return $result . "$text</tgroup></informaltable>";
+ }
+ elsif ($format_command =~ /^(v|f)?table$/)
+ {
+ $result = docbook_add_id('variablelist').'>';
+ if (defined($docbook_table_stack[-1]->{'inter_item'}))
+ { # there is a para in case there is only a comment, to avoid
+ # an empty listitem
+ $text .=
"<listitem><para>$docbook_table_stack[-1]->{'inter_item'}</para></listitem>";
+ }
+ elsif ($docbook_table_stack[-1]->{'varlistentry_state'} == 2)
+ {
+ $text .= "<listitem><para><!-- empty table line
--></para></listitem>";
+ }
+ $text .= '</varlistentry>' if
($docbook_table_stack[-1]->{'varlistentry_state'} >= 1);
+ pop @docbook_table_stack;
+ return $result . "$text</variablelist>\n";
+ }
+}
+
+sub docbook_begin_format_texi($$$)
+{
+ my $command = shift;
+ my $line = shift;
+ my $state = shift;
+
+ push (@docbook_multitable_stack, -1) if ($command eq 'multitable');
+ push (@docbook_table_stack, {'varlistentry_state' => 0}) if ($command =~
/^(v|f)?table/);
+ return $line;
+}
+
+# FIXME
+sub docbook_sp($$)
+{
+ my $number = shift;
+ my $preformatted = shift;
+ return "";
+}
+
+sub docbook_index_summary($$)
+{
+ my $alpha = shift;
+ my $nonalpha = shift;
+ return '';
+}
+
+sub docbook_printindex($$)
+{
+ my $name = shift;
+ return docbook_add_id('index')."></index>\n";
+}
+
+sub docbook_complex_format($$)
+{
+ my $name = shift;
+ my $text = shift;
+ return '' if ($text eq '');
+ my $result = docbook_add_id($docbook_complex_format{$name}).'>'
.$text."</$docbook_complex_format{$name}>";
+ return $result;
+}
+
+sub docbook_format($$)
+{
+ my $name = shift;
+ my $element = shift;
+ my $text = shift;
+ return '' if ($text eq '');
+ return $text if ($format_map{$name} eq '');
+ if ($name eq 'copying')
+ {
+ return "<bookinfo>\n<legalnotice>\n$text</legalnotice>\n</bookinfo>\n";
+ }
+ return docbook_add_id($format_map{$name}).'>'
.$text."</$format_map{$name}>";
+}
+
+sub docbook_quotation_prepend_text($$)
+{
+ my $command = shift;
+ my $argument_text = shift;
+
+ return undef if (!defined($argument_text) or $argument_text =~ /^$/);
+
+ chomp($argument_text);
+ my $text = $argument_text;
+ $text =~ s/^\s*//;
+ $text =~ s/\s*$//;
+
+ return undef if (grep {lc($text) eq $_} @docbook_special_quotation);
+ return &$I('@b{%{quotation_arg}:} ', {'quotation_arg' => $argument_text},
{'keep_texi' => 1});
+}
+
+
+sub docbook_quotation($$$$)
+{
+ my $command = shift;
+ my $text = shift;
+ my $argument_text = shift;
+ my $argument_text_texi = shift;
+
+ $argument_text_texi = '' if (!defined($argument_text_texi));
+ $argument_text_texi =~ s/^\s*//;
+ $argument_text_texi =~ s/\s*$//;
+ my $docbook_command = 'blockquote';
+ if (grep {lc($argument_text_texi) eq $_} @docbook_special_quotation)
+ {
+ $docbook_command = lc($argument_text_texi);
+ }
+ return docbook_add_id($docbook_command).'>' . $text .
"</$docbook_command>\n";
+}
+
+sub docbook_style($$$$$$$$$)
+{
+ my $style = shift;
+ my $command = shift;
+ my $text = shift;
+ my $args = shift;
+ my $no_close =shift;
+ my $no_open = shift;
+ my $line_nr = shift;
+ my $state = shift;
+ my $command_stack = shift;
+
+ my $result = $text;
+ if (exists($style->{'function'}))
+ {
+ my $function = $style->{'function'};
+ $result = &$function($command, $args, $command_stack, $state,
$line_nr);
+ }
+ elsif (exists($style->{'attribute'}))
+ {
+ my $attribute = $style->{'attribute'};
+ my $attribute_text = '';
+ if ($attribute =~ /^(\w+)(\s+.*)/)
+ {
+ $attribute = $1;
+ $attribute_text = $2;
+ }
+
+ $result =
docbook_add_id($attribute)."$attribute_text>$text</$attribute>";
+ }
+ if (exists($style->{'begin'}))
+ {
+ $result = $style->{'begin'} . $result;
+ }
+ if (exists($style->{'end'}))
+ {
+ $result .= $style->{'end'};
+ }
+ return $result;
+}
+
+sub docbook_raw($$$)
+{
+ my $style = shift;
+ my $text = shift;
+ my $line_nr = shift;
+
+ if ($style eq 'verbatim' or $style eq 'verbatiminclude')
+ {
+ return docbook_add_id('screen').'>' . &$protect_text($text) .
'</screen>';
+ }
+ return '' unless (grep {$style eq $_} @EXPAND);
+ if ($style eq 'docbook')
+ {
+ chomp ($text);
+ return $text;
+ }
+ else
+ {
+ main::echo_warn ("Raw style $style not handled", $line_nr);
+ return &$protect_text($text);
+ }
+}
+
+sub docbook_cartouche($$)
+{
+ my $text = shift;
+
+ return "$text";
+}
+
+sub docbook_anchor_label($$)
+{
+ my $id = shift;
+ my $anchor_text = shift;
+ return '<anchor id="'. &$protect_text($anchor_text) . '"></anchor>';
+}
+
+sub docbook_float($$$$$)
+{
+ my $text = shift;
+ my $float = shift;
+ my $caption = shift;
+ my $shortcaption = shift;
+
+ my $label_texi = $float->{'texi'};
+ return $text if (!defined($label_texi) or $label_texi eq '');
+
+ return docbook_anchor_label('',$label_texi) . $text;
+}
+
+sub docbook_normal_text($$$$$$)
+{
+ my $text = shift;
+ my $in_raw_text = shift; # remove_texi
+ my $in_preformatted = shift;
+ my $in_code = shift;
+ my $in_simple = shift;
+#print STDERR "Bug: in_raw_text in_simple $text\n" if ($in_raw_text and
$in_simple);
+ my $style_stack = shift;
+ #$text = uc($text) if (in_cmd($style_stack, 'sc'));
+ $text = &$protect_text($text) unless($in_raw_text);
+ if (! $in_code and !$in_preformatted)
+ {
+ if (!$in_raw_text)
+ {
+ $text =~ s/---/\&mdash\;/g;
+ $text =~ s/--/\&ndash\;/g;
+ $text =~ s/``/\&ldquo\;/g;
+ $text =~ s/''/\&rdquo\;/g;
+ }
+ else
+ {
+ #FIXME really do that ? It is done by makeinfo in hhml
+ $text =~ s/``/"/g;
+ $text =~ s/''/"/g;
+ # temporary reuse '' to store --- !....
+ # FIXME won't '---' be handled wrongly?
+ # FIXME really do that in raw text?
+ $text =~ s/---/''/g;
+ $text =~ s/--/-/g;
+ $text =~ s/''/--/g;
+ }
+ }
+ return $text;
+}
+
+sub docbook_noop
+{
+ return '';
+}
+
+1;
Index: formats/html.init
===================================================================
RCS file: formats/html.init
diff -N formats/html.init
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ formats/html.init 22 May 2009 18:50:29 -0000 1.1
@@ -0,0 +1,3792 @@
+# -*-perl-*-
+######################################################################
+# File: html.init
+#Â html output formatting
+#
+# A copy of this file is pasted into the beginning of texi2html by
+# running './configure'.
+#
+# $Id: html.init,v 1.1 2009/05/22 18:50:29 pertusus Exp $
+
+use strict;
+
+if ($DEFAULT_OUTPUT_FORMAT eq 'html')
+{
+ html_default_load();
+}
+
+#Â initialise the html output
+sub html_default_load()
+{
+
+###############################################################
+# Options common with makeinfo
+# -number | -nonumber
+# if this is set the sections are numbered, and section names and numbers
+# are used in references and menus (instead of node names).
+$NUMBER_SECTIONS = 1;
+
+# -headers
+# if this is set then navigation panels are printed at the beginning of each
+# section.
+# If the document is split at nodes then navigation panels are
+# printed at the end if there were more than $WORDS_IN_PAGE words on page.
+#
+# Navigation panels are always printed at the beginning of output files.
+#
+# This is most useful if you do not want to have section navigation
+# with -split chapter. There will be chapter navigation panel at the
+# beginning and at the end of chapters anyway.
+$SECTION_NAVIGATION = 1;
+
+# -toc-links
+# if this is set, links from headings to toc entries are created.
+$TOC_LINKS = 0;
+
+# -separated-footnotes
+# if this is set footnotes are on a separated page. Otherwise they are at
+# the end of each file (if the document is split).
+$FOOTNOTESTYLE = 'separate';
+
+# --internal-links
+$INTERNAL_LINKS = undef;
+
+# -transliterate-file-names
+# transliterate node names for external refs (and internal if NODE_FILES)
+$TRANSLITERATE_NODE = 1;
+
+# -css-include
+# All the specified css files are used. More precisely the @import sections
+# are added to the beginning of the CSS_LINES the remaining is added at
+# the end of the CSS_LINES (after the css rules generated by texi2html).
+# cf texinfo manual for more info.
+# - means STDIN
address@hidden = ();
+
+# -css-ref
+# the specified url are used as stylesheet links
address@hidden = ();
+
+###############################################################
+#Â specific texi2html options
+# -expand
+# the @EXPAND array contains the expanded section names.
address@hidden = ('html');
+
+# -doctype
+# The value is the 'SystemLiteral' which identifies the canonical DTD
+# for the document.
+# Definition: The SystemLiteral is called the entity's system
+# identifier. It is a URI, which may be used to retrieve the entity.
+# See http://www.xml.com/axml/target.html#NT-ExternalID
+$DOCTYPE = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">';
+
+# -frameset-doctype
+# When frames are used, this SystemLiteral identifies the DTD used for
+# the file containing the frame description.
+$FRAMESET_DOCTYPE = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01
Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">';
+
+# -invisible
+# This seems obsolete and is not used anywhere.
+# This was a workaround for a known bug of many WWW browsers, including
+# netscape. This was used to create invisible destination in anchors.
+$INVISIBLE_MARK = '';
+# $INVISIBLE_MARK = ' ';
+
+# -iso
+# if this value is true, ISO8859 characters are used for special symbols
+# (like copyright, etc).
+$USE_ISO = 1;
+
+# -frames
+# if the value is true, HTML 4.0 "frames" are used.
+# A file describing the frame layout is generated, together with a file
+# with the short table of contents.
+$FRAMES = 0;
+
+# -menu | -nomenu
+# if the value is true the Texinfo menus are shown.
+$SHOW_MENU = 1;
+
+# -use-nodes
+# if this is set the nodes are used as sectionning elements.
+# Otherwise the nodes are incorporated in sections.
+#$USE_NODES = 0;
+$USE_NODES = undef;
+
+$USE_SECTIONS = 1;
+
+# -short-extn
+# If this is set, then all HTML files will have extension ".htm" instead of
+# ".html". This is helpful when shipping the document to DOS-based systems.
+$SHORTEXTN = 0;
+
+# -short-ref
+# if this is set cross-references are given without section numbers.
+$SHORT_REF = '';
+
+# -def-table
+# If this is set a table construction for @def.... instead of definition
+# lists.
+# (New Option: 27.07.2000 Karl Heinz Marbaise)
+$DEF_TABLE = 0;
+
+# -html-xref-prefix
+# base directory for external manuals.
+#$EXTERNAL_DIR = '../';
+$EXTERNAL_DIR = undef;
+
+# -l2h
+# if this is set, latex2html is used for generation of math content.
+$L2H = '';
+
+######################
+# The following options are only relevant if $L2H is set
+#
+# -l2h-l2h
+# name/location of latex2html program
+$L2H_L2H = "latex2html";
+
+# -l2h-skip
+# If this is set the actual call to latex2html is skipped. The previously
+# generated content is reused, instead.
+$L2H_SKIP = '';
+
+# -l2h-tmp
+# If this is set l2h uses the specified directory for temporary files. The path
+# leading to this directory may not contain a dot (i.e., a ".");
+# otherwise, l2h will fail.
+$L2H_TMP = '';
+
+# -l2h-file
+# If set, l2h uses the file as latex2html init file
+$L2H_FILE = 'l2h.init';
+
+# -l2h-clean
+# if this is set the intermediate files generated by texi2html in relation with
+# latex2html are cleaned (they all have the prefix <document name>_l2h_).
+$L2H_CLEAN = 1;
+
+##############################################################################
+#
+# The following can only be set in the init file
+#
+##############################################################################
+
+# if this variable is true, numeric entities are used when there is no
+# corresponding textual entity.
+$USE_NUMERIC_ENTITY = 1;
+
+# if true the link in Overview link to the corresponding Toc entry.
+$OVERVIEW_LINK_TO_TOC = 0;
+
+# if set always separate description and menu link, even in
+# preformatted environment
+$SEPARATE_DESCRIPTION = 0;
+
+# if set, use node anchors for sections targets
+$USE_NODE_TARGET = 1;
+
+# new style for crossrefs
+$NEW_CROSSREF_STYLE = 1;
+
+# top heading is always at the beginning of the element.
+$TOP_HEADING_AT_BEGINNING = 1;
+
+# if set and menu entry equals menu description, then do not print
+# menu description.
+# Likewise, if node name equals entry name, do not print entry name.
+$AVOID_MENU_REDUNDANCY = 1;
+
+#Â if true, use the original command if the result is an entity
+$ENABLE_ENCODING_USE_ENTITY = 1;
+
+# used as identation for block enclosing command @example, etc
+# If not empty, must be enclosed in <td></td>
+$EXAMPLE_INDENT_CELL = '<td> </td>';
+
+# same as above, only for @small
+$SMALL_EXAMPLE_INDENT_CELL = '<td> </td>';
+
+# font size for @small
+$SMALL_FONT_SIZE = '-1';
+
+# horizontal rules
+$SMALL_RULE = '<hr size="1">';
+$DEFAULT_RULE = '<hr>';
+$MIDDLE_RULE = '<hr size="2">';
+$BIG_RULE = '<hr size="6">';
+
+# if set and $SPLIT is set, then split index pages at the next letter
+# after they have more than that many entries
+$SPLIT_INDEX = 100;
+
+# symbol put at the beginning of nodes entry in menu (and optionnaly of
+# unnumbered in menus, see next variable)
+$MENU_SYMBOL = '•';
+#$MENU_SYMBOL = '*';
+
+$SIMPLE_MENU = 0;
+
+# if true put a $MENU_SYMBOL before unnumbered in menus
+$UNNUMBERED_SYMBOL_IN_MENU = 0;
+
+# extension for nodes files when NODE_FILES is true
+$NODE_FILE_EXTENSION = 'html';
+
+# extension
+$EXTENSION = 'html';
+
+# file name used for Top node when NODE_FILES is true
+$TOP_NODE_FILE = 'index';
+
+# this controls the pre style for menus
+$MENU_PRE_STYLE = 'font-family: serif';
+
+# on bug-texinfo is has been said the the style is not code_style
+# for menus (except for the node name).
+# this controls the menu preformatted format
+# FIXME this is not dynamic, so change in MENU_PRE_STYLE is not taken
+# into account.
+$MENU_PRE_COMPLEX_FORMAT = {
+ 'pre_style' => $MENU_PRE_STYLE,
+ 'class' => 'menu-preformatted',
+# 'style' => 'code'
+ };
+
+# This controls the ul style for toc
+$NO_BULLET_LIST_STYLE = 'list-style: none';
+$NO_BULLET_LIST_ATTRIBUTE = ' class="toc"';
+
+# These lines are inserted before and after the shortcontents
+$BEFORE_OVERVIEW = "<div class=\"shortcontents\">\n";
+$AFTER_OVERVIEW = "</div>\n";
+
+# These lines are inserted before and after the contents
+$BEFORE_TOC_LINES = "<div class=\"contents\">\n";
+$AFTER_TOC_LINES = "</div>\n";
+
+# text inserted after <body ...>
+$AFTER_BODY_OPEN = '';
+
+# text inserted before </body>, this will be automatically inside <p></p>
+$PRE_BODY_CLOSE = '';
+
+# this is added inside <head></head> after <title> and some <meta name>
+# stuff, it can be used for eg. <style>, <script>, <meta> etc. tags.
+$EXTRA_HEAD = '';
+
+# Specifies the minimum page length required before a navigation panel
+# is placed at the bottom of a page
+# FIXME this is not true:
+# THIS_WORDS_IN_PAGE holds number of words of current page
+$WORDS_IN_PAGE = 300;
+
+# if this is set a vertical navigation panel is used.
+$VERTICAL_HEAD_NAVIGATION = 0;
+
+# html version for latex2html
+$L2H_HTML_VERSION = "4.0";
+
+# use the information given by menus to complete the node directions
+$USE_MENU_DIRECTIONS = 1;
+
+# try up sections to complete the node directions
+$USE_UP_FOR_ADJACENT_NODES = 1;
+
+# use accesskey in hrefs
+$USE_ACCESSKEY = 0;
+
+# use rel= and rev= in hrefs. Currently only rel is used
+$USE_REL_REV = 0;
+
+# generate <link> elements in head
+$USE_LINKS = 0;
+
+# specify in this array which "buttons" should appear in which order
+# in the navigation panel for sections; use ' ' for empty buttons (space)
address@hidden =
+ (
+ 'Back', 'Forward', ' ', 'FastBack', 'Up', 'FastForward',
+ ' ', ' ', ' ', ' ',
+ 'Top', 'Contents', 'Index', 'About',
+ );
+
+# buttons for misc stuff
address@hidden = ('Top', 'Contents', 'Index', 'About');
+
+# buttons for chapter file footers
+# (and headers but only if SECTION_NAVIGATION is false)
address@hidden =
+ (
+ 'FastBack', 'FastForward', ' ',
+ ' ', ' ', ' ', ' ',
+ 'Top', 'Contents', 'Index', 'About',
+ );
+
+# buttons for section file footers
address@hidden =
+ (
+ 'Back', 'Forward', ' ', 'FastBack', 'Up', 'FastForward'
+ );
+
address@hidden =
+ (
+ 'Back', 'Forward', ' ', 'FastBack', 'Up', 'FastForward',
+ ' ', ' ', ' ', ' ',
+ 'Top', 'Contents', 'Index', 'About',
+# 'Back', 'Forward', ' ', 'FastBack', 'Up', 'FastForward'
+ );
+
address@hidden =
+ (
+ 'Top', 'Index', 'Contents', 'About', 'Up', 'NextFile', 'PrevFile'
+ );
+
+$ICONS = 0;
+
+# insert here name of icon images for buttons
+# Icons are used, if $ICONS and resp. value are set
+%ACTIVE_ICONS =
+ (
+ 'Top', '',
+ 'Contents', '',
+ 'Overview', '',
+ 'Index', '',
+ 'This', '',
+ 'Back', '',
+ 'FastBack', '',
+ 'Prev', '',
+ 'Up', '',
+ 'Next', '',
+ 'NodeUp', '',
+ 'NodeNext', '',
+ 'NodePrev', '',
+ 'Following', '',
+ 'Forward', '',
+ 'FastForward', '',
+ 'About' , '',
+ 'First', '',
+ 'Last', '',
+ 'NextFile', '',
+ 'PrevFile', '',
+ ' ', '',
+ );
+
+# insert here name of icon images for these, if button is inactive
+%PASSIVE_ICONS =
+ (
+ 'Top', '',
+ 'Contents', '',
+ 'Overview', '',
+ 'Index', '',
+ 'This', '',
+ 'Back', '',
+ 'FastBack', '',
+ 'Prev', '',
+ 'Up', '',
+ 'Next', '',
+ 'NodeUp', '',
+ 'NodeNext', '',
+ 'NodePrev', '',
+ 'Following', '',
+ 'Forward', '',
+ 'FastForward', '',
+ 'About', '',
+ 'First', '',
+ 'Last', '',
+ 'NextFile', '',
+ 'PrevFile', '',
+ );
+
+# PRE_ABOUT can be a function reference or a scalar.
+# Note that if it is a scalar, T2H_InitGlobals has not been called,
+# and all global variables like $ADDRESS are not available.
+$PRE_ABOUT = sub
+{
+ return ' ' . &$program_string() . "\n";
+};
+
+# If customizing $AFTER_ABOUT, be sure to put the content inside <p></p>.
+$AFTER_ABOUT = '';
+
+%BUTTONS_EXAMPLE =
+ (
+ 'Top', ' ',
+ 'Contents', ' ',
+ 'Overview', ' ',
+ 'Index', ' ',
+ 'This', '1.2.3',
+ 'Back', '1.2.2',
+ 'FastBack', '1',
+ 'Prev', '1.2.2',
+ 'Up', '1.2',
+ 'Next', '1.2.4',
+ 'NodeUp', '1.2',
+ 'NodeNext', '1.2.4',
+ 'NodePrev', '1.2.2',
+ 'Following', '1.2.4',
+ 'Forward', '1.2.4',
+ 'FastForward', '2',
+ 'About', ' ',
+ 'First', '1.',
+ 'Last', '1.2.4',
+ 'NextFile', ' ',
+ 'PrevFile', ' ',
+ );
+
address@hidden = ('png','jpg','jpeg','gif');
+#, 'txt');
+
+#######################################################################
+#
+# Values guessed if not set here. The value used is in
+# $Texi2HTML::THISDOC{'VARNAME'}
+#
+#######################################################################
+
+$BODYTEXT = undef;
+
+$init_out = \&html_default_init_out;
+
+
+########################################################################
+# Control of Page layout:
+# You can make changes of the Page layout at two levels:
+# 1.) For small changes, it is often enough to change the value of
+# some global string/hash/array variables
+# 2.) For larger changes, reimplement one of the HTML_DEFAULT_<fnc>* routines,
+# give them another name, and assign them to the respective
+# $<fnc> variable.
+
+# As a general interface, the hashes Texi2HTML::HREF, Texi2HTML::NAME,
Texi2HTML::NODE, Texi2HTML::NO_TEXI, Texi2HTML::SIMPLE_TEXT hold
+# href, html-name, node-name, name after removal of texi commands of
+# This -- current section (resp. html page)
+# Top -- top element
+# Contents -- Table of contents element
+# Overview -- Short table of contents element
+# Index -- Index page element
+# About -- page which explain "navigation buttons" element
+# First -- first node element
+# Last -- last node element
+#
+# Whether or not the following hash values are set, depends on the context
+# (all values are w.r.t. 'This' section)
+# Next -- next element of texinfo
+# Prev -- previous element of texinfo
+# NodeUp -- up node of texinfo
+# Following -- following node in node reading order, taking menu into account
+# Forward -- next node in reading order
+# Back -- previous node in reading order
+# Up -- parent given by sectionning commands
+# FastForward -- if leave node, up and next, else next node
+# FastBackward-- if leave node, up and prev, else prev node
+#
+# Furthermore, the following global variabels are set:
+# $Texi2HTML::THISDOC{title} -- title as set by @title...
+# $Texi2HTML::THISDOC{title_no_texi} -- title without texi (without html
elements)
+# $Texi2HTML::THISDOC{title_texi} -- title with texinfo @-commands
+# $Texi2HTML::THISDOC{fulltitle} -- full title as set by @title...
+# $Texi2HTML::THISDOC{subtitle} -- subtitle as set by @subtitle
+# $Texi2HTML::THISDOC{author} -- author as set by @author
+# $Texi2HTML::THISDOC{copying_comment} -- text of @copying and @end copying
in comment
+#
+# $Texi2HTML::THISDOC{program} -- name and version of texi2html
+# $Texi2HTML::THISDOC{program_homepage} -- homepage for texi2html
+# $Texi2HTML::THISDOC{program_authors} -- authors of texi2html
+# $Texi2HTML::THISDOC{today} -- date formatted with pretty_date
+# $Texi2HTML::THISDOC{toc_file} -- table of contents file
+# $Texi2HTML::THISDOC{file_base_name} -- base name of the texinfo manual file
+# $Texi2HTML::THISDOC{input_file_name} -- name of the texinfo manual file
+# $Texi2HTML::THISDOC{destination_directory}
+ # -- directory for the resulting files
+# $Texi2HTML::THISDOC{user} -- user running the script
+# $Texi2HTML::THISDOC{css_import_lines} -- ref on @import lines in css files
+# $Texi2HTML::THISDOC{css_lines} -- ref on css rules lines
+# other $Texi2HTML::THISDOC keys corresponds with texinfo commands, the value
+# being the command arg, for the following commands:
+# kbdinputstyle, paragraphindent, setchapternewpage, headings, footnotestyle,
+# exampleindent, firstparagraphindent, everyheading, everyfooting,
+# evenheading, evenfooting, oddheading, oddfooting
+#
+# and pointer to arrays of lines which need to be printed by main::print_lines
+# $Texi2HTML::THIS_SECTION -- lines of 'This' section
+# $Texi2HTML::OVERVIEW -- lines of short table of contents
+# $Texi2HTML::TOC_LINES -- lines of table of contents
+# $Texi2HTML::TITLEPAGE -- lines of title page
+#
+# $Texi2HTML::THIS_ELEMENT holds the element reference.
+
+#
+# There are the following subs which control the layout:
+#
+$print_section = \&HTML_DEFAULT_print_section;
+$end_section = \&HTML_DEFAULT_end_section;
+$one_section = \&HTML_DEFAULT_one_section;
+$print_Top_header = \&HTML_DEFAULT_print_Top_header;
+$print_Top_footer = \&HTML_DEFAULT_print_Top_footer;
+$print_Top = \&HTML_DEFAULT_print_Top;
+$print_Toc = \&HTML_DEFAULT_print_Toc;
+$print_Overview = \&HTML_DEFAULT_print_Overview;
+$print_Footnotes = \&HTML_DEFAULT_print_Footnotes;
+$print_About = \&HTML_DEFAULT_print_About;
+$print_misc_header = \&HTML_DEFAULT_print_misc_header;
+$print_misc_footer = \&HTML_DEFAULT_print_misc_footer;
+$print_misc = \&HTML_DEFAULT_print_misc;
+$print_section_footer = \&HTML_DEFAULT_print_section_footer;
+$print_chapter_header = \&HTML_DEFAULT_print_chapter_header;
+$print_section_header = \&HTML_DEFAULT_print_section_header;
+$print_element_header = \&HTML_DEFAULT_print_element_header;
+$print_chapter_footer = \&HTML_DEFAULT_print_chapter_footer;
+$print_page_head = \&HTML_DEFAULT_print_page_head;
+$print_page_foot = \&HTML_DEFAULT_print_page_foot;
+$print_head_navigation = \&HTML_DEFAULT_print_head_navigation;
+$print_foot_navigation = \&HTML_DEFAULT_print_foot_navigation;
+$button_icon_img = \&HTML_DEFAULT_button_icon_img;
+$print_navigation = \&HTML_DEFAULT_print_navigation;
+$about_body = \&HTML_DEFAULT_about_body;
+$print_frame = \&HTML_DEFAULT_print_frame;
+$print_toc_frame = \&HTML_DEFAULT_print_toc_frame;
+#$toc_body = \&HTML_DEFAULT_toc_body;
+$titlepage = \&HTML_DEFAULT_titlepage;
+$css_lines = \&HTML_DEFAULT_css_lines;
+$print_redirection_page = \&HTML_DEFAULT_print_redirection_page;
+$node_file_name = \&HTML_DEFAULT_node_file_name;
+$inline_contents = \&HTML_DEFAULT_inline_contents;
+
+########################################################################
+# Control of formatting:
+# 1.) For some changes, it is often enough to change the value of
+# some global map. It might necessitate building a little
+# function along with the change in hash, if the change is the use
+# of another function (in style_map).
+# 2.) For other changes, reimplement one of the t2h_default_<fnc>* routines,
+# give them another name, and assign them to the respective
+# $<fnc> variable (below).
+
+
+#
+# texinfo "simple things" (@foo) to HTML ones
+#
+%simple_map = (
+ '*', "<br>", # HTML+
+ ' ', ' ',
+ "\t", ' ',
+ "\n", ' ',
+ # "­" or "­" could also be possible for @-, but it seems
+ # that some browser will consider this as an always visible hyphen mark
+ # which is not what we want (see http://www.cs.tut.fi/~jkorpela/shy.html)
+ '-', '', # hyphenation hint
+ '|', '', # used in formatting commands @evenfooting and friends
+ '/', '',
+ # spacing commands
+ ':', '',
+ '!', '!',
+ '?', '?',
+ '.', '.',
+ '@', '@',
+ '}', '}',
+ '{', '{',
+ );
+
+# this map is used in preformatted text
+%simple_map_pre = %simple_map;
+$simple_map_pre{'*'} = "\n";
+
+# maps for the math specific commands
+%simple_map_math = (
+ '\\', '\\'
+ );
+
+%simple_map_pre_math = %simple_map_math;
+%simple_map_texi_math = %simple_map_math;
+
+#
+# texinfo "things" (@foo{}) to HTML ones
+#
+%things_map = (
+ 'TeX' => 'TeX',
+ 'LaTeX' => 'LaTeX',
+# pertusus: unknown by makeinfo, not in texinfo manual (@* is the right thing)
+# 'br', '<br>', # paragraph break
+ 'bullet' => '*',
+# #'copyright' => '(C)',
+ 'copyright' => '©',
+ 'registeredsymbol' => '®',
+ 'dots' => '<small class="dots">...</small>',
+ 'enddots' => '<small class="enddots">...</small>',
+ 'equiv' => '==',
+# FIXME i18n
+ 'error' => 'error-->',
+ 'expansion' => '==>',
+ 'arrow' => '->',
+ 'minus' => '-',
+ 'point' => '-!-',
+ 'print' => '-|',
+ 'result' => '=>',
+ # set in code using the language
+ # 'today', &pretty_date,
+ 'today' => '',
+ 'aa' => 'å',
+ 'AA' => 'Å',
+ 'ae' => 'æ',
+ 'oe' => 'œ', #pertusus: also œ. œ
not in html 3.2
+ 'AE' => 'Æ',
+ 'OE' => 'Œ', #pertusus: also Œ. Œ
not in html 3.2
+ 'o' => 'ø',
+ 'O' => 'Ø',
+ 'ss' => 'ß',
+ 'DH' => 'Ð',
+ 'dh' => 'ð',
+ 'TH' => 'Þ',
+ 'th' => 'þ',
+ 'l' => 'ł',
+ 'L' => 'Ł',
+ 'exclamdown' => '¡',
+ 'questiondown' => '¿',
+ 'pounds' => '£',
+ 'ordf' => 'ª',
+ 'ordm' => 'º',
+ 'comma' => ',',
+ 'euro' => '€',
+ 'geq' => '≥',
+ 'leq' => '≤',
+ 'tie' => ' ',
+ 'textdegree' => '°',
+ 'quotedblleft' => '“',
+ 'quotedblright' => '”',
+ 'quoteleft' => '‘',
+ 'quoteright' => '’',
+ 'quotedblbase' => '„',
+ 'quotesinglbase' => '‚',
+ 'guillemetleft' => '«',
+ 'guillemetright' => '»',
+ 'guillemotleft' => '«',
+ 'guillemotright' => '»',
+ 'guilsinglleft' => '‹',
+ 'guilsinglright' => '›',
+ );
+
+# This map is used in preformatted environments
+%pre_map = %things_map;
+$pre_map{'dots'} = '...';
+$pre_map{'enddots'} = '...';
+#$pre_map{'br'} = "\n";
+
+# symbols used for the commands if $USE_ISO is true.
+%iso_symbols = (
+ 'equiv' => '≡',
+ 'dots' => '…',
+ 'bullet' => '•',
+ 'result' => '⇒',
+ 'expansion' => '→',
+ 'arrow' => '→',
+ 'point' => '∗',
+ "'" => '’',
+ '`' => '‘',
+ );
+
+# on bug-texinfo verified that code_style shouldn't be used for anything
+# else than node.
+# anyway it doesn't make sense since the section name normally formatted
+# is used
+#%format_code_style = (
+# 'menu_name' => 1,
+# 'menu_description' => 1
+#);
+
+# default is {'args' => ['normal'], 'attribute' => ''},
+my %style_map_html = (
+ 'b', {'attribute' => 'b'},
+ 'cite', {'attribute' => 'cite'},
+ 'code', {'attribute' => 'code'},
+ 'command', {'attribute' => 'code'},
+ 'dfn', {'attribute' => 'em'},
+ 'email', {'function' => \&html_default_email},
+ 'emph', {'attribute' => 'em'},
+ 'env', {'attribute' => 'code'},
+ 'file', {'attribute' => 'tt', 'quote' => '"'},
+ 'i', {'attribute' => 'i'},
+ 'slanted', {'attribute' => 'i'},
+ 'sansserif', {'attribute' => 'span class="sansserif"'},
+ 'kbd', {'attribute' => 'kbd'},
+ 'key', {'begin' => '<', 'end' => '>'},
+ 'math', {'function' => \&html_default_math},
+ 'option', {'attribute' => 'samp', 'quote' => '"'},
+ 'r', {'attribute' => 'span class="roman"'},
+ 'samp', {'attribute' => 'samp', 'quote' => '"'},
+ 'sc', {'attribute' => 'small'},
+ 'strong', {'attribute' => 'strong'},
+ 't', {'attribute' => 'tt'},
+ 'uref', {'function' => \&html_default_uref},
+ 'url', {'function' => \&html_default_uref},
+ 'indicateurl', {'begin' => '<<code>', 'end' => '</code>>'},
+ 'var', {'attribute' => 'var'},
+ 'verb', {'attribute' => 'tt'},
+ 'titlefont', {'function' => \&html_default_titlefont},
+ );
+
+foreach my $style_command (keys(%style_map_html))
+{
+ foreach my $key (keys(%{$style_map_html{$style_command}}))
+ {
+ $style_map_pre{$style_command}->{$key} =
$style_map_html{$style_command}->{$key};
+ $style_map{$style_command}->{$key} =
$style_map_html{$style_command}->{$key};
+ }
+}
+
+%line_command_map = (
+ 'title' => 'h1',
+ 'subtitle' => 'h3 align="right"',
+ 'author' => 'strong',
+);
+
+%special_accents = (
+ 'ringaccent' => 'aA',
+ "'" => 'aeiouyAEIOUY',
+ ',' => 'cC',
+ '^' => 'aeiouAEIOU',
+ '`' => 'aeiouAEIOU',
+ '~' => 'nNaoAO',
+ '"' => 'aeiouyAEIOU',
+# according to http://www2.lib.virginia.edu/small/vhp/download/ISO.txt
+# however this doesn't seems to work in firefox
+# 'ogonek' => 'aeiuAEIU',
+);
+
+foreach my $accent_command ('tieaccent', 'dotless', keys(%unicode_accents))
+{
+ $style_map{$accent_command} = { 'function' => \&html_default_accent };
+ $style_map_texi{$accent_command} = { 'function' =>
\&t2h_default_ascii_accent };
+}
+
+$style_map_pre{'sc'} = {};
+$style_map_pre{'titlefont'} = {};
+$style_map_pre{'click'}->{'function'} = \&t2h_default_click_pre;
+
+
+#foreach my $command (keys(%style_map))
+#{
+# print STDERR "STYLE_MAP_TEXI $command($style_map_texi{$command}) ";
+# print STDERR "ARGS $style_map_texi{$command}->{'args'} " if
(defined($style_map_texi{$command}->{'args'}));
+# print STDERR "FUN $style_map_texi{$command}->{'function'} " if
(defined($style_map_texi{$command}->{'function'}));
+# print STDERR "\n";
+#}
+
+# uncomment to use the old interface
+#%style_map = %old_style_map;
+#%style_map_pre = %old_style_map_pre;
+
+%simple_format_simple_map_texi = %simple_map_pre;
+%simple_format_texi_map = %pre_map;
+%simple_format_style_map_texi = ();
+
+foreach my $command (keys(%style_map_texi))
+{
+ #$simple_format_style_map_texi{$command} = {};
+ foreach my $key (keys (%{$style_map_texi{$command}}))
+ {
+ #print STDERR "$command, $key, $style_map_texi{$command}->{$key}\n";
+ $simple_format_style_map_texi{$command}->{$key} =
+ $style_map_texi{$command}->{$key};
+ }
+ $simple_format_style_map_texi{$command} = {} if
(!defined($simple_format_style_map_texi{$command}));
+}
+
+foreach my $accent_command ('tieaccent', 'dotless', keys(%unicode_accents))
+{
+# $simple_format_style_map_texi{$accent_command}->{'args'} = ['normal'];
+ $simple_format_style_map_texi{$accent_command}->{'function'} =
\&html_default_accent;
+}
+
+%format_map = (
+# 'quotation' => 'blockquote',
+ # lists
+# 'itemize' => 'ul',
+ 'enumerate' => 'ol',
+# 'multitable' => 'table',
+ 'table' => 'dl compact="compact"',
+ 'vtable' => 'dl compact="compact"',
+ 'ftable' => 'dl compact="compact"',
+ 'group' => '',
+# 'detailmenu' => '',
+ );
+
+%special_list_commands = (
+ 'table' => {},
+ 'vtable' => {},
+ 'ftable' => {},
+ 'itemize' => { 'bullet' => '' }
+ );
+
+#
+# texinfo format to align attribute of paragraphs
+#
+
+%paragraph_style = (
+ 'center' => 'center',
+ 'flushleft' => 'left',
+ 'flushright' => 'right',
+ );
+
+# an eval of these $complex_format_map->{what}->{'begin'} yields beginning
+# an eval of these $complex_format_map->{what}->{'end'} yields end
+# $EXAMPLE_INDENT_CELL and SMALL_EXAMPLE_INDENT_CELL can be usefull here
+$complex_format_map =
+{
+ 'example' =>
+ {
+ 'begin' => q{"<table><tr>$EXAMPLE_INDENT_CELL<td>"},
+ 'end' => q{"</td></tr></table>\n"},
+ 'style' => 'code',
+ },
+ 'smallexample' =>
+ {
+ 'begin' => q{"<table><tr>$SMALL_EXAMPLE_INDENT_CELL<td>"},
+ 'end' => q{"</td></tr></table>\n"},
+ 'style' => 'code',
+ },
+ 'display' =>
+ {
+ 'begin' => q{"<table><tr>$EXAMPLE_INDENT_CELL<td>"},
+ 'end' => q{"</td></tr></table>\n"},
+ },
+ 'smalldisplay' =>
+ {
+ 'begin' => q{"<table><tr>$SMALL_EXAMPLE_INDENT_CELL<td>"},
+ 'end' => q{"</td></tr></table>\n"},
+ }
+};
+
+# format shouldn't narrow the margins
+
+$complex_format_map->{'lisp'} = $complex_format_map->{'example'};
+$complex_format_map->{'smalllisp'} = $complex_format_map->{'smallexample'};
+$complex_format_map->{'format'} = $complex_format_map->{'display'};
+$complex_format_map->{'smallformat'} = $complex_format_map->{'smalldisplay'};
+
+foreach my $format ('menu', 'detailmenu', 'direntry')
+{
+ $complex_format_map->{$format} = { 'begin' => q{''} , 'end' => q{''},
+ 'pre_style' => "$MENU_PRE_STYLE", 'class' => 'menu-preformatted',
+ };
+}
+
+$complex_format_map->{'menu_comment'} = {
+ 'begin' => q{"<tr><th colspan=\"3\" align=\"left\" valign=\"top\">"},
+ 'end' => q{"</th></tr>"}, 'pre_style' => "$MENU_PRE_STYLE", 'class' =>
'menu-comment',
+};
+
+
+%format_in_paragraph = (
+ 'html' => 1,
+);
+# map mapping css specification to style
+
+%css_map =
+ (
+ 'ul.toc' => "$NO_BULLET_LIST_STYLE",
+ 'pre.menu-comment' => "$MENU_PRE_STYLE",
+ 'pre.menu-preformatted' => "$MENU_PRE_STYLE",
+ 'a.summary-letter' => 'text-decoration: none',
+ 'blockquote.smallquotation' => 'font-size: smaller',
+# 'pre.display' => 'font-family: inherit',
+# 'pre.smalldisplay' => 'font-family: inherit; font-size:
smaller',
+ 'pre.display' => 'font-family: serif',
+ 'pre.smalldisplay' => 'font-family: serif; font-size: smaller',
+ 'pre.smallexample' => 'font-size: smaller',
+ 'span.sansserif' => 'font-family:sans-serif;
font-weight:normal;',
+ 'span.roman' => 'font-family:serif; font-weight:normal;'
+ );
+
+$css_map{'pre.format'} = $css_map{'pre.display'};
+$css_map{'pre.smallformat'} = $css_map{'pre.smalldisplay'};
+$css_map{'pre.smalllisp'} = $css_map{'pre.smallexample'};
+
+
+# formatting functions
+
+$anchor = \&html_default_anchor;
+$def_item = \&html_default_def_item;
+$def = \&html_default_def;
+$menu_command = \&html_default_menu_command;
+$menu_link = \&html_default_menu_link;
+$menu_description = \&html_default_menu_description;
+$external_ref = \&html_default_external_ref;
+$external_href = \&html_default_external_href;
+$internal_ref = \&html_default_internal_ref;
+$table_item = \&html_default_table_item;
+$table_line = \&html_default_table_line;
+$table_list = \&html_default_table_list;
+$row = \&html_default_row;
+$cell = \&html_default_cell;
+$list_item = \&html_default_list_item;
+$comment = \&html_default_comment;
+$def_line = \&html_default_def_line;
+$raw = \&html_default_raw;
+$heading = \&html_default_heading;
+$element_heading = \&html_default_element_heading;
+$paragraph = \&html_default_paragraph;
+$preformatted = \&html_default_preformatted;
+$foot_line_and_ref = \&html_default_foot_line_and_ref;
+$foot_section = \&html_default_foot_section;
+$image_files = \&html_default_image_files;
+$image = \&html_default_image;
+$index_entry_label = \&html_default_index_entry_label;
+$index_summary = \&html_default_index_summary;
+#$summary_letter = \&html_default_summary_letter;
+$index_entry = \&html_default_index_entry;
+$index_entry_command = \&html_default_index_entry_command;
+$index_letter = \&html_default_index_letter;
+#$printindex = \&html_default_printindex;
+$print_index = \&html_default_print_index;
+$protect_text = \&html_default_protect_text;
+$normal_text = \&html_default_normal_text;
+$complex_format = \&html_default_complex_format;
+$cartouche = \&html_default_cartouche;
+$sp = \&html_default_sp;
+$copying_comment = \&html_default_copying_comment;
+$documentdescription = \&html_default_documentdescription;
+$empty_line = \&html_default_empty_line;
+$caption_shortcaption = \&html_default_caption_shortcaption;
+$caption_shortcaption_command = \&html_default_caption_shortcaption_command;
+$float = \&html_default_float;
+$listoffloats = \&html_default_listoffloats;
+$listoffloats_entry = \&html_default_listoffloats_entry;
+$listoffloats_caption = \&html_default_listoffloats_caption;
+$listoffloats_float_style = \&html_default_listoffloats_float_style;
+$acronym_like = \&html_default_acronym_like;
+$quotation = \&html_default_quotation;
+$paragraph_style_command = \&html_default_paragraph_style_command;
+$element_label = \&html_default_element_label;
+$misc_element_label = \&html_default_misc_element_label;
+$anchor_label = \&html_default_anchor_label;
+$format_list_item_texi = \&html_default_format_list_item_texi;
+$begin_format_texi = \&html_default_begin_format_texi;
+$tab_item_texi = \&html_default_tab_item_texi;
+$insertcopying = \&html_default_insertcopying;
+$line_command = \&html_default_line_command;
+
+}
+
+my @html_default_multitable_stack;
+# tracks menu entry index
+my $html_menu_entry_index;
+
+
+
+#Â The functions
+
+# We have to do this dynamically because of internationalization and because
+# in body $DOCUMENTLANGUAGE could be used.
+sub html_default_init_out()
+{
+ &t2h_default_init_out;
+ @html_default_multitable_stack = ();
+ # Set the default body text, inserted between <body ... >
+ if (defined($BODYTEXT))
+ {
+ $Texi2HTML::THISDOC{'BODYTEXT'} = $BODYTEXT;
+ }
+ else
+ {
+ $Texi2HTML::THISDOC{'BODYTEXT'} = 'lang="' .
get_conf('documentlanguage') . '" bgcolor="#FFFFFF" text="#000000"
link="#0000FF" vlink="#800080" alink="#FF0000"';
+ }
+}
+
+########################################################################
+# Page formatting functions
+#
+
+########################################################################
+# Layout for html for every sections
+#
+
+sub HTML_DEFAULT_print_element_header
+{
+ my $first_in_page = shift;
+ my $previous_is_top = shift;
+ my $buttons = address@hidden;
+
+ if (($first_in_page or $previous_is_top) and $SECTION_NAVIGATION)
+ {
+ return &$print_head_navigation(undef, $buttons);
+ }
+ else
+ { # got to do this here, as it isn't done in print_head_navigation
+ return &$print_navigation($buttons) if ($SECTION_NAVIGATION or
get_conf('SPLIT') eq 'node');
+ }
+}
+
+sub HTML_DEFAULT_print_section
+{
+ my $fh = shift;
+ my $first_in_page = shift;
+ my $previous_is_top = shift;
+ my $element = shift;
+ my $buttons = address@hidden;
+
+ my $nw = main::print_lines($fh);
+ if ((get_conf('SPLIT') eq 'node') && $SECTION_NAVIGATION)
+ {
+ my $buttons = address@hidden;
+ &$print_foot_navigation($fh, $buttons, $SMALL_RULE,
+ (!defined($WORDS_IN_PAGE) or (defined ($nw) and $nw >=
$WORDS_IN_PAGE)),
+ $element);
+# print $fh "$SMALL_RULE\n";
+# &$print_navigation($buttons) if (!defined($WORDS_IN_PAGE) or (defined
($nw)
+# and $nw >= $WORDS_IN_PAGE));
+ }
+}
+
+sub HTML_DEFAULT_one_section($$)
+{
+ my $fh = shift;
+ my $element = shift;
+ main::print_lines($fh);
+ print $fh "$SMALL_RULE\n";
+ &$print_page_foot($fh);
+}
+
+###################################################################
+# Layout of top-page I recommend that you use @ifnothtml, @ifhtml,
+# @html within the Top texinfo node to specify content of top-level
+# page.
+#
+# If you enclose everything in @ifnothtml, then title, subtitle,
+# author and overview is printed
+# Texi2HTML::HREF of Next, Prev, Up, Forward, Back are not defined
+# if $T2H_SPLIT then Top page is in its own html file
+sub HTML_DEFAULT_print_Top_header($$)
+{
+ my $fh = shift;
+ my $do_page_head = shift;
+ &$print_page_head($fh) if ($do_page_head);
+}
+sub HTML_DEFAULT_print_Top_footer($$$)
+{
+ my $fh = shift;
+ my $end_page = shift;
+ my $element = shift;
+ my $buttons = address@hidden;
+ &$print_foot_navigation($fh, $buttons, $SMALL_RULE,
+ ($end_page and ($SECTION_NAVIGATION or (get_conf('SPLIT') and
get_conf('SPLIT') ne 'node'))), $element);
+# &$print_foot_navigation($fh);
+# print $fh "$SMALL_RULE\n";
+ if ($end_page)
+ {
+# &$print_navigation($fh, $buttons);
+ &$print_page_foot($fh);
+ }
+}
+
+sub HTML_DEFAULT_print_Top($$$)
+{
+ my $fh = shift;
+ my $has_top_heading = shift;
+ my $element = shift;
+
+ # a dirty hack. A section is considered to be empty if there are 2
+ # lines or less in it. Indeed, this catches the sectionning command like
+ # @top and the @node.
+ if (scalar(@$Texi2HTML::THIS_SECTION) > 2)
+ {
+ # if top-level node has content
+ main::print_lines($fh, $Texi2HTML::THIS_SECTION);
+ }
+ else
+ {
+ # top-level node is fully enclosed in @ifnothtml
+ # redo the titlepage with the actual state
+ my ($titlepage_text, $titlepage_no_texi, $titlepage_simple_format) =
main::do_special_region_lines('titlepage',$Texi2HTML::THISDOC{'state'});
+
+ &$titlepage([],$titlepage_text, $titlepage_no_texi,
$titlepage_simple_format);
+ # only print the header and node label
+ print $fh $Texi2HTML::THIS_SECTION->[0];
+ print $fh $Texi2HTML::TITLEPAGE;
+ if (@{$Texi2HTML::OVERVIEW} and
!$Texi2HTML::THISDOC{'setshortcontentsaftertitlepage'})
+ {
+ print $fh '<h2> ' . $Texi2HTML::NAME{'Overview'} . "</h2>\n" .
"<blockquote\n";
+ main::print_lines($fh, $Texi2HTML::OVERVIEW);
+ print $fh "</blockquote>\n";
+ }
+ elsif (@{$Texi2HTML::TOC_LINES} and
!$Texi2HTML::THISDOC{'setcontentsaftertitlepage'})
+ {
+ print $fh '<h1> ' . $Texi2HTML::NAME{'Contents'} . "</h1>\n";
+ main::print_lines($fh, $Texi2HTML::TOC_LINES);
+ }
+ }
+}
+
+###################################################################
+# Layout of Toc, Overview, and Footnotes pages
+# By default, we use "normal" layout
+# Texi2HTML::HREF of Next, Prev, Up, Forward, Back, etc are not defined
+# use: my $buttons = [...] to redefine navigation buttons
+sub HTML_DEFAULT_print_Toc
+{
+ return &$print_misc(@_);
+}
+sub HTML_DEFAULT_print_Overview
+{
+ return &$print_misc(@_);
+}
+sub HTML_DEFAULT_print_Footnotes
+{
+ return &$print_misc(@_);
+}
+sub HTML_DEFAULT_print_About
+{
+ # if there is no section navigation and it is not split, the
+ # navigation information is useless
+ return &$print_misc(@_) if (get_conf('SPLIT') or $SECTION_NAVIGATION);
+}
+
+sub HTML_DEFAULT_print_misc_header
+{
+ my $fh = shift;
+ my $buttons = shift;
+ my $new_file = shift;
+ my $misc_page = shift;
+ &$print_page_head($fh) if ($new_file);
+ print $fh "".&$misc_element_label($misc_pages_targets{$misc_page},
$misc_page);
+ &$print_head_navigation($fh, $buttons) if ($new_file or
$SECTION_NAVIGATION);
+}
+
+sub HTML_DEFAULT_print_misc_footer
+{
+ my $fh = shift;
+ my $buttons = shift;
+ my $new_file = shift;
+ &$print_foot_navigation($fh, $buttons, $SMALL_RULE,
+ ($new_file and ($SECTION_NAVIGATION or (get_conf('SPLIT') and
get_conf('SPLIT') ne 'node'))), undef);
+# print $fh "$SMALL_RULE\n";
+ if ($new_file)
+ {
+ &$print_page_foot($fh);
+ }
+}
+
+sub HTML_DEFAULT_print_misc
+{
+ my $fh = shift;
+ my $new_file = shift;
+ my $misc_page = shift;
+ my $buttons = address@hidden;
+ &$print_misc_header($fh, $buttons, $new_file, $misc_page);
+ print $fh "<h1>$Texi2HTML::NAME{This}</h1>\n";
+ main::print_lines($fh);
+ &$print_misc_footer($fh, $buttons, $new_file);
+}
+##################################################################
+# section_footer is only called if SPLIT eq 'section'
+# section_footer: after print_section of last section, before print_page_foot
+#
+
+sub HTML_DEFAULT_print_section_footer
+{
+ my $fh = shift;
+ my $element = shift;
+ my $buttons = address@hidden;
+ &$print_foot_navigation($fh, $buttons, $BIG_RULE, 1, $element);
+# &$end_section ($fh, 1, $element);
+# &$print_navigation($fh, $buttons);
+}
+
+###################################################################
+# chapter_header and chapter_footer are only called if
+# SPLIT eq 'chapter'
+# chapter_header: after print_page_head, before print_section
+# chapter_footer: after print_section of last section, before print_page_foot
+#
+# If you want to get rid of navigation stuff after each section,
+# redefine print_section such that it does not call print_navigation,
+# and put print_navigation into print_chapter_header
+sub HTML_DEFAULT_print_chapter_header
+{
+ my $fh = shift;
+ my $element = shift;
+ # nothing to do there, by default, the navigation panel
+ # is the section navigation panel
+ if (! $SECTION_NAVIGATION)
+ { # in this case print_navigation is called here.
+ my $buttons = address@hidden;
+ &$print_head_navigation($fh, $buttons);
+ print $fh "\n$MIDDLE_RULE\n" unless ($VERTICAL_HEAD_NAVIGATION);
+ }
+}
+
+sub HTML_DEFAULT_print_chapter_footer
+{
+ my $fh = shift;
+ my $element = shift;
+ my $buttons = address@hidden;
+ &$print_foot_navigation($fh, $buttons, $BIG_RULE, 1, $element);
+# print $fh "$BIG_RULE\n";
+# &$print_navigation($fh, $buttons);
+}
+
+sub HTML_DEFAULT_print_section_header
+{
+ # nothing to do there, by default
+ if (! $SECTION_NAVIGATION)
+ { # in this case print_navigation is called here.
+ my $fh = shift;
+ my $buttons = address@hidden;
+ &$print_head_navigation($fh, $buttons);
+ }
+}
+
+
+###################################################################
+# Layout of standard header and footer
+#
+
+sub HTML_DEFAULT_print_page_head($)
+{
+ my $fh = shift;
+ my $longtitle = "$Texi2HTML::THISDOC{'fulltitle_simple_format'}";
+ $longtitle .= ": $Texi2HTML::SIMPLE_TEXT{'This'}" if (defined
($Texi2HTML::SIMPLE_TEXT{'This'}) and ($Texi2HTML::SIMPLE_TEXT{'This'} !~
/^\s*$/) and get_conf('SPLIT'));
+ my $description = $Texi2HTML::THISDOC{'DOCUMENT_DESCRIPTION'};
+ $description = $longtitle if (!defined($description));
+ $description = "<meta name=\"description\" content=\"$description\">" if
+ ($description ne '');
+ my $encoding = '';
+ $encoding = "<meta http-equiv=\"Content-Type\" content=\"text/html;
charset=$Texi2HTML::THISDOC{'ENCODING_NAME'}\">" if
(defined($Texi2HTML::THISDOC{'ENCODING_NAME'}) and
($Texi2HTML::THISDOC{'ENCODING_NAME'} ne ''));
+ my $links = '';
+ if ($USE_LINKS)
+ {
+ foreach my $link (@LINKS_BUTTONS)
+ {
+#print STDERR "$link!!$Texi2HTML::HREF{$link}\n";
+ if (defined($Texi2HTML::HREF{$link}) and $Texi2HTML::HREF{$link}
ne '')
+ {
+ my $title = '';
+ $title = " title=\"$Texi2HTML::SIMPLE_TEXT{$link}\"" if
(defined($Texi2HTML::SIMPLE_TEXT{$link}));
+ my $rel = '';
+ $rel = " rel=\"$BUTTONS_REL{$link}\"" if
(defined($BUTTONS_REL{$link}));
+ $links .= "<link
href=\"$Texi2HTML::HREF{$link}\"${rel}${title}>\n";
+ }
+ }
+ }
+
+ print $fh <<EOT;
+$DOCTYPE
+<html>
+$Texi2HTML::THISDOC{'copying_comment'}<!-- Created on
$Texi2HTML::THISDOC{today} by $Texi2HTML::THISDOC{program}
+$Texi2HTML::THISDOC{program_authors}-->
+<head>
+<title>$longtitle</title>
+
+$description
+<meta name="keywords" content="$longtitle">
+<meta name="resource-type" content="document">
+<meta name="distribution" content="global">
+<meta name="Generator" content="$Texi2HTML::THISDOC{program}">
+$encoding
+${links}$Texi2HTML::THISDOC{'CSS_LINES'}
+$EXTRA_HEAD
+</head>
+
+<body $Texi2HTML::THISDOC{'BODYTEXT'}>
+$AFTER_BODY_OPEN
+EOT
+}
+
+sub HTML_DEFAULT_end_section($$$)
+{
+ my $fh = shift;
+ my $misc_and_section_separation = shift;
+ my $element = shift;
+ #&$print_foot_navigation($fh) if ($end_foot_navigation);
+ #print $fh "$BIG_RULE\n";
+ if ($misc_and_section_separation)
+ {
+ &$print_foot_navigation($fh, undef, $BIG_RULE, 0, $element);
+ }
+ else
+ {
+ print $fh "$BIG_RULE\n";
+ }
+}
+
+sub HTML_DEFAULT_print_page_foot($)
+{
+ my $fh = shift;
+ my $program_string = &$program_string();
+ print $fh <<EOT;
+<p>
+ <font size="-1">
+ $program_string
+ </font>
+ <br>
+$PRE_BODY_CLOSE
+</p>
+</body>
+</html>
+EOT
+}
+
+###################################################################
+# Layout of navigation panel
+
+sub HTML_DEFAULT_print_head_navigation($$)
+{
+ my $fh = shift;
+ my $buttons = shift;
+
+ my $result = '';
+ if ($VERTICAL_HEAD_NAVIGATION)
+ {
+ $result .= <<EOT;
+<table border="0" cellpadding="0" cellspacing="0">
+<tr valign="top">
+<td align="left">
+EOT
+ }
+ $result .= &$print_navigation($buttons, $VERTICAL_HEAD_NAVIGATION);
+ if ($VERTICAL_HEAD_NAVIGATION)
+ {
+ $result .= <<EOT;
+</td>
+<td align="left">
+EOT
+ }
+ elsif (get_conf('SPLIT') eq 'node')
+ {
+ $result .= "$SMALL_RULE\n";
+ }
+
+ print $fh $result if (defined($fh));
+ return $result;
+}
+
+sub HTML_DEFAULT_print_foot_navigation
+{
+ my $fh = shift;
+ my $buttons = shift;
+ my $rule = shift;
+ my $print_navigation_panel = shift;
+ my $element = shift;
+
+ $rule = '' if (!defined($rule));
+ $print_navigation_panel = 1 if (!defined($print_navigation_panel)
+ and defined($buttons));
+
+ if ($VERTICAL_HEAD_NAVIGATION)
+ {
+ print $fh <<EOT;
+</td>
+</tr>
+</table>
+EOT
+ }
+ print $fh "$rule\n" if ($rule ne '');
+ print $fh "".&$print_navigation($buttons) if ($print_navigation_panel);
+}
+
+######################################################################
+# navigation panel
+#
+# how to create IMG tag
+sub HTML_DEFAULT_button_icon_img
+{
+ my $button = shift;
+ my $icon = shift;
+ my $name = shift;
+ return '' if (!defined($icon));
+ $button = "" if (!defined ($button));
+ $name = '' if (!defined($name));
+ my $alt = '';
+ if ($name ne '')
+ {
+ if ($button ne '')
+ {
+ $alt = "$button: $name";
+ }
+ else
+ {
+ $alt = $name;
+ }
+ }
+ else
+ {
+ $alt = $button;
+ }
+ return qq{<img src="$icon" border="0" alt="$alt" align="middle">};
+}
+
+sub HTML_DEFAULT_print_navigation
+{
+ my $buttons = shift;
+ my $vertical = shift;
+
+ my $result = '';
+ $result .= '<table cellpadding="1" cellspacing="1" border="0">'."\n";
+ $result .= "<tr>" unless $vertical;
+ for my $button (@$buttons)
+ {
+ $result .= qq{<tr valign="top" align="left">\n} if $vertical;
+ $result .= qq{<td valign="middle" align="left">};
+
+ if (ref($button) eq 'CODE')
+ {
+ $result .= &$button($vertical);
+ }
+ elsif (ref($button) eq 'SCALAR')
+ {
+ $result .= "$$button" if defined($$button);
+ }
+ elsif (ref($button) eq 'ARRAY')
+ {
+ my $text = $button->[1];
+ my $button_href = $button->[0];
+ # verify that $button_href is simple text and text is a reference
+ if (defined($button_href) and !ref($button_href)
+ and defined($text) and (ref($text) eq 'SCALAR') and
defined($$text))
+ { # use given text
+ if ($Texi2HTML::HREF{$button_href})
+ {
+ my $anchor_attributes = '';
+ if ($USE_ACCESSKEY and
(defined($BUTTONS_ACCESSKEY{$button_href})) and
($BUTTONS_ACCESSKEY{$button_href} ne ''))
+ {
+ $anchor_attributes =
"accesskey=\"$BUTTONS_ACCESSKEY{$button_href}\"";
+ }
+ if ($USE_REL_REV and (defined($BUTTONS_REL{$button_href}))
and ($BUTTONS_REL{$button_href} ne ''))
+ {
+ $anchor_attributes .= "
rel=\"$BUTTONS_REL{$button_href}\"";
+ }
+ $result .= "" .
+ &$anchor('',
+ $Texi2HTML::HREF{$button_href},
+ $$text,
+ $anchor_attributes
+ )
+ ;
+ }
+ else
+ {
+ $result .= $$text;
+ }
+ }
+ }
+ elsif ($button eq ' ')
+ { # handle space button
+ $result .=
+ ($ICONS && $ACTIVE_ICONS{' '}) ?
+ &$button_icon_img($BUTTONS_NAME{$button}, $ACTIVE_ICONS{'
'}) :
+ $NAVIGATION_TEXT{' '};
+ #next;
+ }
+ elsif ($Texi2HTML::HREF{$button})
+ { # button is active
+ my $btitle = $BUTTONS_GOTO{$button} ?
+ 'title="' . $BUTTONS_GOTO{$button} . '"' : '';
+ if ($USE_ACCESSKEY and (defined($BUTTONS_ACCESSKEY{$button})) and
($BUTTONS_ACCESSKEY{$button} ne ''))
+ {
+ $btitle .= " accesskey=\"$BUTTONS_ACCESSKEY{$button}\"";
+ }
+ if ($USE_REL_REV and (defined($BUTTONS_REL{$button})) and
($BUTTONS_REL{$button} ne ''))
+ {
+ $btitle .= " rel=\"$BUTTONS_REL{$button}\"";
+ }
+ if ($ICONS && $ACTIVE_ICONS{$button})
+ { # use icon
+ $result .= '' .
+ &$anchor('',
+ $Texi2HTML::HREF{$button},
+ &$button_icon_img($BUTTONS_NAME{$button},
+ $ACTIVE_ICONS{$button},
+ $Texi2HTML::SIMPLE_TEXT{$button}),
+ $btitle
+ );
+ }
+ else
+ { # use text
+ $result .=
+ '[' .
+ &$anchor('',
+ $Texi2HTML::HREF{$button},
+ $NAVIGATION_TEXT{$button},
+ $btitle
+ ) .
+ ']';
+ }
+ }
+ else
+ { # button is passive
+ $result .=
+ $ICONS && $PASSIVE_ICONS{$button} ?
+ &$button_icon_img($BUTTONS_NAME{$button},
+ $PASSIVE_ICONS{$button},
+ $Texi2HTML::SIMPLE_TEXT{$button}) :
+
+ "[" . $NAVIGATION_TEXT{$button}
. "]";
+ }
+ $result .= "</td>\n";
+ $result .= "</tr>\n" if $vertical;
+ }
+ $result .= "</tr>" unless $vertical;
+ $result .= "</table>\n";
+ return $result;
+}
+
+######################################################################
+# Frames: this is from "Richard Y. Kim" <address@hidden>
+# Should be improved to be more conforming to other _print* functions
+# toc_file and main_file passed as args are relative to the texinfo manual
+# location, and therefore are not used.
+
+sub HTML_DEFAULT_print_frame
+{
+ my $fh = shift;
+ my $toc_file = shift;
+ my $main_file = shift;
+ $main_file = $Texi2HTML::THISDOC{'filename'}->{'top'};
+ $toc_file = $Texi2HTML::THISDOC{'filename'}->{'toc_frame'};
+ print $fh <<EOT;
+$FRAMESET_DOCTYPE
+<html>
+<head><title>$Texi2HTML::THISDOC{'fulltitle'}</title></head>
+<frameset cols="140,*">
+ <frame name="toc" src="$toc_file">
+ <frame name="main" src="$main_file">
+</frameset>
+</html>
+EOT
+}
+
+sub HTML_DEFAULT_print_toc_frame
+{
+ my $fh = shift;
+ my $stoc_lines = shift;
+ &$print_page_head($fh);
+ print $fh <<EOT;
+<h2>Content</h2>
+EOT
+ print $fh map {s/\bhref=/target="main" href=/; $_;} @$stoc_lines;
+ print $fh "</body></html>\n";
+}
+
+# This subroutine is intended to fill @Texi2HTML::TOC_LINES and
+# @Texi2HTML::OVERVIEW with the table of contents and short table of
+# contents.
+#
+# arguments:
+# ref on an array containing all the elements
+
+# each element is a reference on a hash. The following keys might be of
+# use:
+# 'top': true if this is the top element
+# 'toc_level': level of the element in the table of content. Highest level
+# is 1 for the @top element and for chapters, appendix and so on,
+# 2 for section, unnumberedsec and so on...
+# 'tocid': label used for reference linking to the element in table of
+# contents
+# 'file': the file containing the element, usefull to do href to that file
+# in case the document is split.
+# 'text': text of the element, with section number
+# 'text_nonumber': text of the element, without section number
+
+# Relevant configuration variables are:
+# $NUMBER_SECTIONS
+# $NO_BULLET_LIST_ATTRIBUTE: usefull in case a list is used
+# $FRAMES: @Texi2HTML::OVERVIEW is used in one of the frames.
+# $BEFORE_OVERVIEW
+# $AFTER_OVERVIEW
+# $BEFORE_TOC_LINES
+# $AFTER_TOC_LINES
+# $CONTENTS
+# $SHORTCONTENTS
+
+sub HTML_DEFAULT_toc_body($)
+{
+}
+
+sub HTML_DEFAULT_inline_contents($$$)
+{
+ my $fh = shift;
+ my $command = shift;
+ my $element = shift;
+ my $name;
+ my $lines;
+
+ my $result = undef;
+
+ if ($command eq 'contents')
+ {
+ $name = $Texi2HTML::NAME{'Contents'};
+ $lines = $Texi2HTML::TOC_LINES;
+ }
+ else
+ {
+ $name = $Texi2HTML::NAME{'Overview'};
+ $lines = $Texi2HTML::OVERVIEW;
+ }
+ if (@{$lines})
+ {
+ $result = [ "".&$anchor($element->{'id'})."\n",
+ "<h1>$name</h1>\n" ];
+ push @$result, @$lines;
+ }
+
+ return $result;
+}
+
+sub HTML_DEFAULT_css_lines ($$)
+{
+ my $import_lines = shift;
+ my $rule_lines = shift;
+# return if (defined($CSS_LINES) or (address@hidden and address@hidden and
(! keys(%css_map))));
+ if (defined($CSS_LINES))
+ { # if predefined, use CSS_LINES.
+ $Texi2HTML::THISDOC{'CSS_LINES'} = $CSS_LINES;
+ return;
+ }
+ return if (address@hidden and address@hidden and (! keys(%css_map)));
+ my $css_lines = "<style type=\"text/css\">\n<!--\n";
+ $css_lines .= join('',@$import_lines) . "\n" if (@$import_lines);
+ foreach my $css_rule (sort(keys(%css_map)))
+ {
+ next unless ($css_map{$css_rule});
+ $css_lines .= "$css_rule {$css_map{$css_rule}}\n";
+ }
+ $css_lines .= join('',@$rule_lines) . "\n" if (@$rule_lines);
+ $css_lines .= "-->\n</style>\n";
+ foreach my $ref (@CSS_REFS)
+ {
+ $css_lines .= "<link rel=\"stylesheet\" type=\"text/css\"
href=\"$ref\">\n";
+ }
+ $Texi2HTML::THISDOC{'CSS_LINES'} = $css_lines;
+}
+
+######################################################################
+# About page
+#
+
+sub HTML_DEFAULT_about_body
+{
+ my $about = "<p>\n";
+ if (ref($PRE_ABOUT) eq 'CODE')
+ {
+ $about .= &$PRE_ABOUT();
+ }
+ else
+ {
+ $about .= $PRE_ABOUT;
+ }
+ $about .= <<EOT;
+</p>
+<p>
+EOT
+ $about .= &$I(' The buttons in the navigation panels have the following
meaning:') . "\n";
+ $about .= <<EOT;
+</p>
+<table border="1">
+ <tr>
+EOT
+ $about .= ' <th> ' . &$I('Button') . " </th>\n" .
+' <th> ' . &$I('Name') . " </th>\n" .
+' <th> ' . &$I('Go to') . " </th>\n" .
+' <th> ' . &$I('From 1.2.3 go to') . "</th>\n" . " </tr>\n";
+
+ for my $button (@SECTION_BUTTONS)
+ {
+ next if $button eq ' ' || ref($button) eq 'CODE' || ref($button) eq
'SCALAR' || ref($button) eq 'ARRAY';
+ $about .= " <tr>\n <td align=\"center\">";
+ $about .=
+ ($ICONS && $ACTIVE_ICONS{$button} ?
+ &$button_icon_img($BUTTONS_NAME{$button}, $ACTIVE_ICONS{$button})
:
+ ' [' . $NAVIGATION_TEXT{$button} . '] ');
+ $about .= "</td>\n";
+ $about .= <<EOT;
+ <td align="center">$BUTTONS_NAME{$button}</td>
+ <td>$BUTTONS_GOTO{$button}</td>
+ <td>$BUTTONS_EXAMPLE{$button}</td>
+ </tr>
+EOT
+ }
+
+ $about .= <<EOT;
+</table>
+
+<p>
+EOT
+ $about .= &$I(' where the @strong{ Example } assumes that the current
position is at @strong{ Subsubsection One-Two-Three } of a document of the
following structure:') . "\n";
+
+# where the <strong> Example </strong> assumes that the current position
+# is at <strong> Subsubsection One-Two-Three </strong> of a document of
+# the following structure:
+ $about .= <<EOT;
+</p>
+
+<ul>
+EOT
+ $about .= ' <li> 1. ' . &$I('Section One') . "\n" .
+" <ul>\n" .
+' <li>1.1 ' . &$I('Subsection One-One') . "\n";
+ $about .= <<EOT;
+ <ul>
+ <li>...</li>
+ </ul>
+ </li>
+EOT
+ $about .= ' <li>1.2 ' . &$I('Subsection One-Two') . "\n" .
+" <ul>\n" .
+' <li>1.2.1 ' . &$I('Subsubsection One-Two-One') . "</li>\n" .
+' <li>1.2.2 ' . &$I('Subsubsection One-Two-Two') . "</li>\n" .
+' <li>1.2.3 ' . &$I('Subsubsection One-Two-Three') . "
\n"
+.
+' <strong><== ' . &$I('Current Position') . " </strong></li>\n" .
+' <li>1.2.4 ' . &$I('Subsubsection One-Two-Four') . "</li>\n" .
+" </ul>\n" .
+" </li>\n" .
+' <li>1.3 ' . &$I('Subsection One-Three') . "\n";
+ $about .= <<EOT;
+ <ul>
+ <li>...</li>
+ </ul>
+ </li>
+EOT
+ $about .= ' <li>1.4 ' . &$I('Subsection One-Four') . "</li>\n";
+ $about .= <<EOT;
+ </ul>
+ </li>
+</ul>
+$AFTER_ABOUT
+EOT
+ return $about;
+}
+
+# return value is currently ignored
+sub HTML_DEFAULT_titlepage($$$$)
+{
+ my $titlepage_lines = shift;
+ my $titlepage_text = shift;
+ my $titlepage_no_texi = shift;
+ my $titlepage_simple_format = shift;
+
+ $Texi2HTML::TITLEPAGE = $titlepage_text;
+ if ($titlepage_text eq '')
+ {
+ my $title = '';
+ $title = $Texi2HTML::THISDOC{'title'} if
(defined($Texi2HTML::THISDOC{'title'}) and $Texi2HTML::THISDOC{'title'} !~
/^\s*$/);
+ if ($title ne '')
+ {
+ $Texi2HTML::TITLEPAGE = '<h1
align="center">'."$title</h1>\n$DEFAULT_RULE\n";
+ }
+ }
+
+ if ($Texi2HTML::THISDOC{'setcontentsaftertitlepage'} and
(defined($Texi2HTML::THISDOC{'inline_contents'}->{'contents'})) and
@{$Texi2HTML::THISDOC{'inline_contents'}->{'contents'}})
+ {
+ foreach my
$line(@{$Texi2HTML::THISDOC{'inline_contents'}->{'contents'}})
+ {
+ $Texi2HTML::TITLEPAGE .= $line;
+ }
+ $Texi2HTML::TITLEPAGE .= "$DEFAULT_RULE\n";
+ }
+ if ($Texi2HTML::THISDOC{'setshortcontentsaftertitlepage'} and
(defined($Texi2HTML::THISDOC{'inline_contents'}->{'shortcontents'})) and
@{$Texi2HTML::THISDOC{'inline_contents'}->{'shortcontents'}})
+ {
+ foreach my
$line(@{$Texi2HTML::THISDOC{'inline_contents'}->{'shortcontents'}})
+ {
+ $Texi2HTML::TITLEPAGE .= $line;
+ }
+ $Texi2HTML::TITLEPAGE .= "$DEFAULT_RULE\n";
+ }
+ return $Texi2HTML::TITLEPAGE;
+}
+
+# FIXME Honor DOCUMENT_DESCRIPTION?
+sub HTML_DEFAULT_print_redirection_page($)
+{
+ my $fh = shift;
+ my $longtitle = "$Texi2HTML::THISDOC{'fulltitle_simple_format'}";
+ $longtitle .= ": $Texi2HTML::SIMPLE_TEXT{'This'}" if exists
$Texi2HTML::SIMPLE_TEXT{'This'};
+ my $description = $longtitle;
+ my $encoding = '';
+ $encoding = "<meta http-equiv=\"Content-Type\" content=\"text/html;
charset=$Texi2HTML::THISDOC{'ENCODING_NAME'}\">" if
(defined($Texi2HTML::THISDOC{'ENCODING_NAME'}) and
($Texi2HTML::THISDOC{'ENCODING_NAME'} ne ''));
+ my $href = &$anchor('', $Texi2HTML::HREF{'This'},
$Texi2HTML::NAME{'This'});
+ my $string = &$I('The node you are looking for is at %{href}.',
+ { 'href' => $href });
+ print $fh <<EOT;
+$DOCTYPE
+<html>
+<!-- Created on $Texi2HTML::THISDOC{'today'} by $Texi2HTML::THISDOC{'program'}
-->
+<!--
+$Texi2HTML::THISDOC{'program_authors'}
+-->
+<head>
+<title>$longtitle</title>
+
+<meta name="description" content="$description">
+<meta name="keywords" content="$longtitle">
+<meta name="resource-type" content="document">
+<meta name="distribution" content="global">
+<meta name="Generator" content="$Texi2HTML::THISDOC{program}">
+$encoding
+$Texi2HTML::THISDOC{'CSS_LINES'}
+<meta http-equiv="Refresh" content="2; url=$Texi2HTML::HREF{'This'}">
+$EXTRA_HEAD
+</head>
+
+<body $Texi2HTML::THISDOC{'BODYTEXT'}>
+$AFTER_BODY_OPEN
+<p>$string</p>
+</body>
+EOT
+}
+
+sub HTML_DEFAULT_node_file_name($$)
+{
+ my $node = shift;
+ my $type = shift;
+ return undef if ($node->{'external_node'}
+ or ($type eq 'top' and !$NEW_CROSSREF_STYLE));
+ my $node_file_base;
+ if ($type eq 'top' and defined($TOP_NODE_FILE))
+ {
+ $node_file_base = $TOP_NODE_FILE;
+ }
+ elsif ($NEW_CROSSREF_STYLE)
+ {
+ if ($TRANSLITERATE_NODE)
+ {
+ $node_file_base = $node->{'cross_manual_file'};
+ }
+ else
+ {
+ $node_file_base = $node->{'cross_manual_target'};
+ }
+ }
+ else
+ {
+ $node_file_base = main::remove_texi($node->{'texi'});
+ $node_file_base =~ s/[^\w\.\-]/-/g;
+ }
+ if (defined($NODE_FILE_EXTENSION) and $NODE_FILE_EXTENSION ne '')
+ {
+ return ($node_file_base . ".$NODE_FILE_EXTENSION");
+ }
+ return $node_file_base;
+}
+
+sub html_default_accent($$)
+{
+ my $accent = shift;
+ my $args = shift;
+
+ my $text = $args->[0];
+
+ return "&${text}$accent_map{$accent};" if (defined($accent_map{$accent})
and defined($special_accents{$accent}) and ($text =~
/^[$special_accents{$accent}]$/));
+ return '&' . $text . 'ring;' if (($accent eq 'ringaccent') and
(defined($special_accents{$accent})) and ($text =~
/^[$special_accents{$accent}]$/));
+ return $text . '<' if ($accent eq 'v');
+# FIXME here there could be a conversion to the character in the right
+# encoding, like
+# if ($USE_UNICODE and defined($OUT_ENCODING) and $OUT_ENCODING ne ''
+# and exists($unicode_accents{$accent}) and
exists($unicode_accents{$accent}->{$text}))
+# {
+# my $encoded_char = Encode::encode($OUT_ENCODING,
chr(hex($unicode_map{$thing})), Encode::FB_QUIET);
+# return $encoded_char if ($encoded_char ne '');
+# }
+ if ($USE_NUMERIC_ENTITY)
+ {
+ if (exists($unicode_accents{$accent}) and
exists($unicode_accents{$accent}->{$text}))
+ {
+ return ('&#' . hex($unicode_accents{$accent}->{$text}) . ';');
+ }
+ }
+ return ascii_accents($text, $accent);
+}
+
+# Avoid adding h1 if the text is empty
+sub html_default_titlefont($$$)
+{
+ shift;
+ my $args = shift;
+ return "<h1 class=\"titlefont\">$args->[0]</h1>" if ($args->[0] =~ /\S/);
+ return '';
+}
+
+# At some point in time (before 4.7?) according to the texinfo
+# manual, url shouldn't lead to a link but rather be formatted
+# like text. It is now what indicateurl do, url is the same that
+# uref with one arg. If we did like makeinfo did it would have been
+#sub url($$)
+#{
+# return '<<code>' . $_[0] . '</code>>';
+#}
+#
+# This is unused, html_default_uref is used instead
+sub html_default_url ($$)
+{
+ shift;
+ my $args = shift;
+ my $url = shift @$args;
+ #$url =~ s/\s*$//;
+ #$url =~ s/^\s*//;
+ $url = main::normalise_space($url);
+ return '' unless ($url =~ /\S/);
+ return &$anchor('', $url, $url);
+}
+
+sub html_default_uref($$)
+{
+ shift;
+ my $args = shift;
+ my $url = shift @$args;
+ my $text = shift @$args;
+ my $replacement = shift @$args;
+ #$url =~ s/\s*$//;
+ #$url =~ s/^\s*//;
+ $url = main::normalise_space($url);
+ $replacement = '' if (!defined($replacement));
+ $replacement = main::normalise_space($replacement);
+ $text = '' if (!defined($text));
+ $text = main::normalise_space($text);
+ $text = $replacement if ($replacement ne '');
+ $text = $url unless ($text ne '');
+ return $text if ($url eq '');
+ return &$anchor('', $url, $text);
+}
+
+sub html_default_math($$)
+{
+ shift;
+ my $args = shift;
+ my $text = shift @$args;
+#print STDERR "html_default_math $text\n";
+ $text =~ s/[{}]//g;
+# $text =~ s/address@hidden/\\/g;
+ return "<em>$text</em>";
+}
+
+sub html_default_email($$)
+{
+ my $command = shift;
+ my $args = shift;
+ my $mail = shift @$args;
+ my $text = shift @$args;
+ $mail = main::normalise_space($mail);
+ #$mail =~ s/\s*$//;
+ #$mail =~ s/^\s*//;
+ $text = $mail unless (defined($text) and ($text ne ''));
+ $text = main::normalise_space($text);
+ return $text if ($mail eq '');
+ return &$anchor('', "mailto:$mail", $text);
+}
+
+# this is called each time a format begins. Here it is used to keep a
+# record of the multitables to have a faithful count of the cell nr.
+sub html_default_begin_format_texi($$$)
+{
+ my $command = shift;
+ my $line = shift;
+ my $state = shift;
+
+ # first array element is the number of cell in a row
+ # second is the number of paragraphs in a cell
+ push (@html_default_multitable_stack, [-1,-1]) if ($command eq
'multitable');
+
+ return $line;
+}
+
+# This function is called whenever a complex format is processed
+#
+# arguments:
+# name of the format
+# text appearing inside the format
+#
+# an eval of $complex_format->{format name}->{'begin'} should lead to the
+# beginning of the complex format, an eval of
+# $complex_format->{format name}->{'end'} should lead to the end of the
+# complex format.
+sub html_default_complex_format($$)
+{
+ my $name = shift;
+ my $text = shift;
+ return '' if ($text eq '');
+ my $beginning = eval "$complex_format_map->{$name}->{'begin'}";
+ if ($@ ne '')
+ {
+ warn "Evaluation of $complex_format_map->{$name}->{'begin'}: $@";
+ $beginning = '';
+
+ }
+ my $end = eval "$complex_format_map->{$name}->{'end'}";
+ if ($@ ne '')
+ {
+ warn "Evaluation of $complex_format_map->{$name}->{'end'}: $@";
+ $end = '';
+
+ }
+ return $beginning . $text . $end;
+}
+
+sub html_default_empty_line($$)
+{
+ my $text = shift;
+ my $state = shift;
+ #ignore the line if it just follows a deff
+ return '' if ($state->{'deff_line'});
+ return $text;
+}
+
+sub html_default_caption_shortcaption($)
+{
+ my $float = shift;
+ my $caption_lines;
+ my $shortcaption_lines;
+ my $style = $float->{'style_texi'};
+ if (defined($float->{'nr'}))
+ {
+ my $nr = $float->{'nr'};
+ if ($style ne '')
+ {
+ $style = &$I('%{style} %{number}', { 'style' => $style, 'number'
=> $nr});
+ }
+ else
+ {
+ $style = $nr;
+ }
+ }
+
+ if (defined($float->{'caption_texi'}))
+ {
+ @$caption_lines = @{$float->{'caption_texi'}};
+ $caption_lines->[0] =~ s/^\s*//;
+ if (defined($style))
+ {
+ $caption_lines->[0] = '@'.$CAPTION_STYLE.'{' . &$I('%{style}:
%{caption_first_line}', { 'style' => $style, 'caption_first_line' =>
$caption_lines->[0] });
+ }
+ else
+ {
+ $caption_lines->[0] = '@'.$CAPTION_STYLE.'{' .
$caption_lines->[0];
+ }
+ push @$caption_lines, "}\n";
+ }
+ elsif (defined($style))
+ {
+ $caption_lines->[0] = '@'.$CAPTION_STYLE.'{' . $style . '}' . "\n";
+ }
+ if (defined($float->{'shortcaption_texi'}))
+ {
+ @$shortcaption_lines = @{$float->{'shortcaption_texi'}};
+ if (defined($style))
+ {
+ $shortcaption_lines->[0] = '@'.$CAPTION_STYLE.'{' .
&$I('%{style}: %{shortcaption_first_line}', { 'style' => $style,
'shortcaption_first_line' => $shortcaption_lines->[0] });
+ }
+ else
+ {
+ $shortcaption_lines->[0] = '@'.$CAPTION_STYLE.'{' .
$shortcaption_lines->[0];
+ }
+ push @$shortcaption_lines, "}\n";
+ }
+ elsif (defined($style))
+ {
+ $shortcaption_lines->[0] = '@'.$CAPTION_STYLE.'{' . $style . '}' .
"\n";
+ }
+ return ($caption_lines, $shortcaption_lines);
+}
+
+# everything is done in &$float
+sub html_default_caption_shortcaption_command($$$$)
+{
+ my $command = shift;
+ my $text = shift;
+ my $texi_lines = shift;
+ my $float_element = shift;
+ return '';
+}
+
+sub html_default_float($$$$$)
+{
+ my $text = shift;
+ my $float = shift;
+ my $caption = shift;
+ my $shortcaption = shift;
+
+ my $label = '';
+ if (exists($float->{'id'}))
+ {
+ $label = &$anchor($float->{'id'});
+ }
+ my $caption_text = '';
+
+ if (defined($float->{'caption_texi'}))
+ {
+ $caption_text = $caption;
+ }
+ elsif (defined($float->{'shortcaption_texi'}))
+ {
+ $caption_text = $shortcaption;
+ }
+ elsif (defined($caption))
+ {
+ $caption_text = $caption;
+ }
+
+ return '<div class="float">' . "$label\n" . $text . '</div>' .
$caption_text;
+}
+
+sub html_default_listoffloats_float_style($$)
+{
+ my $style_texi = shift;
+ my $float = shift;
+
+ my $style = $float->{'style_texi'};
+ #print STDERR "listoffloat/float style mismatch $style_texi $style\n" if
($style_texi ne $style);
+ if (defined($float->{'nr'}))
+ {
+ my $nr = $float->{'nr'};
+ if ($style ne '')
+ {
+ $style = &$I('%{style} %{number}', { 'style' => $style, 'number'
=> $nr});
+ }
+ else
+ {
+ $style = $nr;
+ }
+ }
+ return $style;
+}
+
+sub html_default_listoffloats_caption($)
+{
+ my $float = shift;
+ if (defined($float->{'shortcaption_texi'}))
+ {
+ return ([ @{$float->{'shortcaption_texi'}} ], 'shortcaption');
+ }
+ elsif (defined($float->{'caption_texi'}))
+ {
+ return ([ @{$float->{'caption_texi'}} ], 'caption');
+ }
+ return ([ ], undef);
+}
+
+sub html_default_listoffloats_entry($$$$)
+{
+ my $style_texi = shift;
+ my $float = shift;
+ my $float_style = shift;
+ my $caption = shift;
+ my $href = shift;
+
+ return '<dt>' . &$anchor('', $href, $float_style) . '</dt><dd>' . $caption
+. '</dd>' . "\n";
+}
+
+sub html_default_listoffloats($$$)
+{
+ my $style_texi = shift;
+ my $style = shift;
+ my $float_entries = shift;
+
+ my $result = "<dl class=\"listoffloats\">\n" ;
+ foreach my $float_entry (@$float_entries)
+ {
+ $result .= $float_entry;
+ }
+ return $result . "</dl>\n";
+}
+
+sub html_default_insertcopying($$$)
+{
+ my $text = shift;
+ my $comment = shift;
+ my $simple_text = shift;
+ return $text;
+}
+
+# This function is used to protect characters which are special in html
+# in inline text: &, ", <, and >.
+#
+# argument:
+# text to be protected
+sub html_default_protect_text($)
+{
+ my $text = shift;
+ $text =~ s/&/&/g;
+ $text =~ s/</</g;
+ $text =~ s/>/>/g;
+ $text =~ s/\"/"/g;
+ return $text;
+}
+
+sub html_default_normal_text($$$$$$;$)
+{
+ my $text = shift;
+ my $in_raw_text = shift; # remove_texi
+ my $in_preformatted = shift;
+ my $in_code = shift;
+ my $in_simple = shift;
+ my $style_stack = shift;
+ my $state = shift;
+
+ # like utf8.init
+ if ($ENABLE_ENCODING and !$ENABLE_ENCODING_USE_ENTITY and
defined($Texi2HTML::THISDOC{'ENCODING_NAME'}) and
$Texi2HTML::THISDOC{'ENCODING_NAME'} eq 'utf-8')
+ {
+ return t2h_utf8_normal_text($text, $in_raw_text, $in_preformatted,
$in_code, $in_simple, $style_stack, $state);
+ }
+
+ $text = uc($text) if (in_cmd($style_stack, 'sc'));
+ $text = &$protect_text($text) unless($in_raw_text);
+ if (! $in_code and !$in_preformatted)
+ {
+ if ($USE_ISO and !$in_raw_text)
+ {
+ $text =~ s/---/\&mdash\;/g;
+ $text =~ s/--/\&ndash\;/g;
+ $text =~ s/``/\&ldquo\;/g;
+ $text =~ s/''/\&rdquo\;/g;
+ if (! $in_simple)
+ { # lquot and rquot don't seem to be accepted in title.
+ $text =~ s/'/$iso_symbols{"'"}/g if (defined
($iso_symbols{"'"}));
+ $text =~ s/`/$iso_symbols{'`'}/g if (defined
($iso_symbols{'`'}));
+ }
+ }
+ else
+ {
+ if ($in_raw_text) #FIXME really do that ? It is done by makeinfo
+ {
+ $text =~ s/``/"/g;
+ $text =~ s/''/"/g;
+ }
+ else
+ {
+ $text =~ s/``/"/g;
+ $text =~ s/''/"/g;
+ # to be like texinfo
+ #$text =~ s/'/\&rsquo\;/g;
+ #$text =~ s/`/\&lsquo\;/g;
+ }
+ # temporary reuse '' to store --- !....
+ # FIXME won't '---' be handled wrongly?
+ # FIXME really do that in raw text?
+ $text =~ s/---/''/g;
+ $text =~ s/--/-/g;
+ $text =~ s/''/--/g;
+ }
+ }
+ else
+ {
+ # to be like texinfo
+# my $special_code = 0;
+# $special_code = 1 if (in_cmd($style_stack, 'code') or
+# in_cmd($style_stack, 'example') or in_cmd($style_stack,
'verbatim'));
+# $text =~ s/'/\&rsquo\;/g unless ($special_code and
exists($main::value{'txicodequoteundirected'}));
+# $text =~ s/`/\&lsquo\;/g unless ($special_code and
exists($main::value{'txicodequotebacktick'}));
+ }
+ return $text;
+}
+
+# This function produces an anchor
+#
+# arguments:
+# $name : anchor name
+# $href : anchor href
+# text : text displayed
+# extra_attribs : added to anchor attributes list
+sub html_default_anchor($;$$$)
+{
+ my $name = shift;
+ my $href = shift;
+ my $text = shift;
+ my $attributes = shift;
+#print STDERR "!$name!$href!$text!$attributes!\n";
+ if (!defined($attributes) or ($attributes !~ /\S/))
+ {
+ $attributes = '';
+ }
+ else
+ {
+ $attributes = ' ' . $attributes;
+ }
+ $name = '' if (!defined($name) or ($name !~ /\S/));
+ $href = '' if (!defined($href) or ($href !~ /\S/));
+ $text = '' if (!defined($text));
+ return $text if (($name eq '') and ($href eq ''));
+ $name = "name=\"$name\"" if ($name ne '');
+ $href = "href=\"$href\"" if ($href ne '');
+ $href = ' ' . $href if (($name ne '') and ($href ne ''));
+#print STDERR "!!!$name!$href!$text!$attributes!\n";
+ return "<a ${name}${href}${attributes}>$text</a>";
+}
+
+# This function is used to format the text associated with a @deff/@end deff
+#
+# argument:
+# text
+#
+# $DEF_TABLE should be used to distinguish between @def formatted as table
+# and as definition lists.
+sub html_default_def_item($$$)
+{
+ my $text = shift;
+ my $only_inter_item_commands = shift;
+ my $command = shift;
+ if ($text =~ /\S/)
+ {
+ if (! $DEF_TABLE)
+ {
+ return '<dd>' . $text . '</dd>';# unless $only_inter_item_commands;
+ #return $text; # invalid without dd in ul
+ }
+ else
+ {
+ return '<tr><td colspan="2">' . $text . '</td></tr>';
+ }
+ }
+ return '';
+}
+
+# format the container for the @deffn line and text
+#
+# argument
+# text of the whole @def, line and associated text.
+#
+# $DEF_TABLE should be used.
+sub html_default_def($$)
+{
+ my $text = shift;
+ my $command = shift;
+ if ($text =~ /\S/)
+ {
+ if (! $DEF_TABLE)
+ {
+ return "<dl>\n" . $text . "</dl>\n";
+ }
+ else
+ {
+ return "<table width=\"100%\">\n" . $text . "</table>\n";
+ }
+ }
+ return '';
+
+}
+
+# a whole menu
+#
+# argument:
+# the whole menu text (entries and menu comments)
+#
+# argument:
+# whole menu text.
+sub html_default_menu_command($$$)
+{
+ my $format = shift;
+ my $text = shift;
+ my $in_preformatted = shift;
+
+ $html_menu_entry_index=0;
+
+ my $begin_row = '';
+ my $end_row = '';
+ if ($in_preformatted)
+ {
+ $begin_row = '<tr><td>';
+ $end_row = '</td></tr>';
+ }
+ if ($text =~ /\S/)
+ {
+ return '' if ($format eq 'direntry');
+ return $text if ($format eq 'detailmenu');
+ return "<table class=\"menu\" border=\"0\"
cellspacing=\"0\">${begin_row}\n"
+ . $text . "${end_row}</table>\n";
+ }
+}
+
+# formats a menu entry link pointing to a node or section
+#
+# arguments:
+# the entry text
+# the state, a hash reference holding informations about the context, with a
+# usefull entry, 'preformatted', true if we are in a preformatted format
+# (a format keeping space between words). In that case a function
+# of the main program, main::do_preformatted($text, $state) might
+# be used to format the text with the current format style.
+# href is optionnal. It is the reference to the section or the node anchor
+# which should be used to make the link (typically it is the argument
+# of a href= attribute in a <a> element).
+sub html_default_menu_link($$$$$$$$)
+{
+ my $entry = shift;
+ my $state = shift;
+ my $href = shift;
+ my $node = shift;
+ my $title = shift;
+ my $ending = shift;
+ my $has_title = shift;
+ my $command_stack = shift;
+ my $preformatted = shift;
+
+ my $in_commands = 0;
+ $in_commands = 1 if ($command_stack->[-1] and $command_stack->[-1] ne
'menu' and $command_stack->[-1] ne 'detailmenu' and $command_stack->[-1] ne
'direntry');
+
+ $title = '' unless ($has_title);
+#print STDERR "MENU_LINK($in_commands)($state->{'preformatted'})\n";
+ if (($entry eq '') or $NODE_NAME_IN_MENU or $preformatted)
+ {
+ $title .= ':' if ($title ne '');
+ $entry = "$MENU_SYMBOL$title$node";
+ }
+ $html_menu_entry_index++;
+ my $accesskey;
+ $accesskey = "accesskey=\"$html_menu_entry_index\"" if ($USE_ACCESSKEY and
($html_menu_entry_index < 10));
+ $entry = &$anchor ('', $href, $entry, $accesskey) if (defined($href));
+
+ return $entry.$ending if ($preformatted);
+ return $entry .' ' if ($in_commands);
+ return "<tr><td align=\"left\"
valign=\"top\">$entry</td><td> </td>";
+}
+
+sub html_simplify_text($)
+{
+ my $text = shift;
+ $text =~ s/[^\w]//og;
+ return $text;
+}
+
+# formats a menu entry description, ie the text appearing after the node
+# specification in a menu entry an spanning until there is another
+# menu entry, an empty line or some text at the very beginning of the line
+# (we consider that text at the beginning of the line begins a menu comment)
+#
+# arguments:
+# the description text
+# the state. See menu_entry.
+# the heading of the element associated with the node.
+sub html_default_menu_description($$$$)
+{
+ my $text = shift;
+ my $state = shift;
+ my $element_text = shift;
+ my $command_stack = shift;
+ my $preformatted = shift;
+
+ my $in_commands = 0;
+ $in_commands = 1 if ($command_stack->[-1] and $command_stack->[-1] ne
'menu' and $command_stack->[-1] ne 'detailmenu' and $command_stack->[-1] ne
'direntry');
+ return $text if ($preformatted or $in_commands);
+ # FIXME: the following is better-looking.
+ #return $text."<br>" if ($in_commands and !$state->{'preformatted'});
+ if ($AVOID_MENU_REDUNDANCY)
+ {
+ $text = '' if (html_simplify_text($element_text) eq
html_simplify_text($text));
+ }
+ return "<td align=\"left\" valign=\"top\">$text</td></tr>\n";
+}
+
+# Construct a href to an external source of information.
+# node is the node with texinfo @-commands
+# node_id is the node transliterated and transformed as explained in the
+# texinfo manual
+# node_xhtml_id is the node transformed such that it is unique and can
+# be used to make an html cross ref as explained in the texinfo manual
+# file is the file in '(file)node'
+sub html_default_external_href($$$)
+{
+ my $node = shift;
+ my $node_id = shift;
+ my $node_xhtml_id = shift;
+ my $file = shift;
+ $file = '' if (!defined($file));
+ my $default_target_split = $Texi2HTML::THISDOC{'EXTERNAL_CROSSREF_SPLIT'};
+ my $target_split;
+ my $target_mono;
+ my $href_split;
+ my $href_mono;
+ if ($file ne '')
+ {
+ if ($NEW_CROSSREF_STYLE)
+ {
+ $file =~ s/\.[^\.]*$//;
+ $file =~ s/^.*\///;
+ my $href;
+ if (exists($Texi2HTML::THISDOC{'htmlxref'}->{$file}))
+ {
+ if
(exists($Texi2HTML::THISDOC{'htmlxref'}->{$file}->{'split'}))
+ {
+ $target_split = 1;
+ $href_split =
$Texi2HTML::THISDOC{'htmlxref'}->{$file}->{'split'}->{'href'};
+ }
+ if
(exists($Texi2HTML::THISDOC{'htmlxref'}->{$file}->{'mono'}))
+ {
+ $target_mono = 1;
+ $href_mono =
$Texi2HTML::THISDOC{'htmlxref'}->{$file}->{'mono'}->{'href'};
+ }
+ }
+
+ if ((not $target_mono) and (not $target_split))
+ { # nothing specified for that manual, use default
+ $target_split = $default_target_split;
+ }
+ elsif ($target_split and $target_mono)
+ { # depends on the splitting of the manual
+ $target_split = get_conf('SPLIT');
+ }
+ elsif ($target_mono)
+ { # only mono specified
+ $target_split = 0;
+ }
+
+ if ($target_split)
+ {
+ if (defined($href_split))
+ {
+ $file = "$href_split";
+ }
+ elsif (defined($EXTERNAL_DIR))
+ {
+ $file = "$EXTERNAL_DIR/$file";
+ }
+ elsif (get_conf('SPLIT'))
+ {
+ $file = "../$file";
+ }
+ $file .= "/";
+ }
+ else
+ {# target not split
+ if (defined($href_mono))
+ {
+ $file = "$href_mono";
+ }
+ else
+ {
+ if (defined($EXTERNAL_DIR))
+ {
+ $file = "$EXTERNAL_DIR/$file";
+ }
+ elsif (get_conf('SPLIT'))
+ {
+ $file = "../$file";
+ }
+ $file .= "." . $NODE_FILE_EXTENSION;
+ }
+ }
+ }
+ else
+ {
+ $file .= "/";
+ if (defined($EXTERNAL_DIR))
+ {
+ $file = $EXTERNAL_DIR . $file;
+ }
+ else
+ {
+ $file = '../' . $file;
+ }
+ }
+ }
+ else
+ {
+ $target_split = $default_target_split;
+ }
+ if ($node eq '')
+ {
+ if ($NEW_CROSSREF_STYLE)
+ {
+ if ($target_split)
+ {
+ return $file . $TOP_NODE_FILE . '.' . $NODE_FILE_EXTENSION .
'#Top';
+ # or ?
+ #return $file . '#Top';
+ }
+ else
+ {
+ return $file . '#Top';
+ }
+ }
+ else
+ {
+ return $file;
+ }
+ }
+ my $target;
+ if ($NEW_CROSSREF_STYLE)
+ {
+ $node = $node_id;
+ $target = $node_xhtml_id;
+ }
+ else
+ {
+ $node = main::remove_texi($node);
+ $node =~ s/[^\w\.\-]/-/g;
+ }
+ my $file_basename = $node;
+ $file_basename = $TOP_NODE_FILE if ($node =~ /^top$/i);
+ if ($NEW_CROSSREF_STYLE)
+ {
+ if ($target_split)
+ {
+ return $file . $file_basename . ".$NODE_FILE_EXTENSION" . '#' .
$target;
+ }
+ else
+ {
+ return $file . '#' . $target;
+ }
+ }
+ else
+ {
+ return $file . $file_basename . ".$NODE_FILE_EXTENSION";
+ }
+}
+
+# format a reference external to the generated manual. This produces a full
+# reference with introductive words and the reference itself.
+#
+# arguments:
+# type of the reference: xref (reference at the beginning of a sentence),
+# pxref (reference in a parenthesis),
+# section in the book. This might be undef.
+# book name.
+# node and file name formatted according to the convention used in info
+# '(file)node' and no node means the Top node.
+# href linking to the html page containing the referenced node. A typical
+# use for this href is a href attribute in an <a> element
+# an optionnal cross reference name
+sub html_default_external_ref($$$$$$$$)
+{
+ my $type = shift;
+ my $section = shift;
+ my $book = shift;
+ my $file_node = shift;
+ my $href = shift;
+ my $cross_ref = shift;
+ my $args_texi = shift;
+ my $formatted_args = shift;
+
+ $file_node = "$cross_ref: $file_node" if (($file_node ne '') and
($cross_ref ne ''));
+ $file_node = &$anchor('', $href, $file_node) if ($file_node ne '');
+
+ # Yes, this is ugly, but this helps internationalization
+ if ($type eq 'pxref')
+ {
+ if (($book ne '') and ($file_node ne ''))
+ {
+ return &$I('see %{node_file_href} section `%{section}\' in
@cite{%{book}}', { 'node_file_href' => $file_node, 'book' => $book, 'section'
=> $section },{'duplicate'=>1}) if ($section ne '');
+ return &$I('see %{node_file_href} @cite{%{book}}', {
'node_file_href' => $file_node, 'book' => $book },{'duplicate'=>1});
+ }
+ elsif ($book ne '')
+ {
+ return &$I('see section `%{section}\' in @cite{%{book}}', {
'book' => $book, 'section' => $section },{'duplicate'=>1}) if ($section ne '');
+ return &$I('see @cite{%{book}}', { 'book' => $book
},{'duplicate'=>1});
+ }
+ elsif ($file_node ne '')
+ {
+ return &$I('see %{node_file_href}', { 'node_file_href' =>
$file_node },{'duplicate'=>1});
+ }
+ }
+ if ($type eq 'xref' or $type eq 'inforef')
+ {
+ if (($book ne '') and ($file_node ne ''))
+ {
+ return &$I('See %{node_file_href} section `%{section}\' in
@cite{%{book}}', { 'node_file_href' => $file_node, 'book' => $book, 'section'
=> $section },{'duplicate'=>1}) if ($section ne '');
+ return &$I('See %{node_file_href} @cite{%{book}}', {
'node_file_href' => $file_node, 'book' => $book },{'duplicate'=>1});
+ }
+ elsif ($book ne '')
+ {
+ return &$I('See section `%{section}\' in @cite{%{book}}', {
'book' => $book, 'section' => $section },{'duplicate'=>1}) if ($section ne '');
+ return &$I('See @cite{%{book}}', { 'book' => $book
},{'duplicate'=>1});
+ }
+ elsif ($file_node ne '')
+ {
+ return &$I('See %{node_file_href}', { 'node_file_href' =>
$file_node },{'duplicate'=>1});
+ }
+ }
+ if ($type eq 'ref')
+ {
+ if (($book ne '') and ($file_node ne ''))
+ {
+ return &$I('%{node_file_href} section `%{section}\' in
@cite{%{book}}', { 'node_file_href' => $file_node, 'book' => $book, 'section'
=> $section },{'duplicate'=>1}) if ($section ne '');
+ return &$I('%{node_file_href} @cite{%{book}}', {
'node_file_href' => $file_node, 'book' => $book },{'duplicate'=>1});
+ }
+ elsif ($book ne '')
+ {
+ return &$I('section `%{section}\' in @cite{%{book}}', { 'book'
=> $book, 'section' => $section },{'duplicate'=>1}) if ($section ne '');
+ return &$I('@cite{%{book}}', { 'book' => $book
},{'duplicate'=>1});
+ }
+ elsif ($file_node ne '')
+ {
+ return &$I('%{node_file_href}', { 'node_file_href' => $file_node
},{'duplicate'=>1});
+ }
+ }
+ return '';
+}
+
+# format a reference to a node or a section in the generated manual. This
+# produces a full reference with introductive words and the reference itself.
+#
+# arguments:
+# type of the reference: xref (reference at the beginning of a sentence),
+# pxref (reference in a parenthesis),
+# href linking to the html page containing the node or the section. A typical
+# use for this href is a href attribute in an <a> element
+# short name for this reference
+# name for this reference
+# boolean true if the reference is a reference to a section
+#
+# $SHORT_REF should be used.
+sub html_default_internal_ref($$$$$$$$)
+{
+ my $type = shift;
+ my $href = shift;
+ my $short_name = shift;
+ my $name = shift;
+ my $is_section = shift;
+ my $args_texi = shift;
+ my $formatted_args = shift;
+ my $element = shift;
+
+ if (! $SHORT_REF)
+ {
+ $name = &$anchor('', $href, $name);
+ if ($type eq 'pxref')
+ {
+ return &$I('see section %{reference_name}', { 'reference_name' =>
$name },{'duplicate'=>1}) if ($is_section);
+ return &$I('see %{reference_name}', { 'reference_name' => $name
},{'duplicate'=>1});
+ }
+ elsif ($type eq 'xref' or $type eq 'inforef')
+ {
+ return &$I('See section %{reference_name}', { 'reference_name' =>
$name },{'duplicate'=>1}) if ($is_section);
+ return &$I('See %{reference_name}', { 'reference_name' => $name
},{'duplicate'=>1});
+ }
+ elsif ($type eq 'ref')
+ {
+ return &$I('%{reference_name}', { 'reference_name' => $name
},{'duplicate'=>1});
+ }
+ }
+ else
+ {
+ $name = &$anchor('', $href, $short_name);
+ if ($type eq 'pxref')
+ {
+ return &$I('see %{reference_name}', { 'reference_name' => $name
},{'duplicate'=>1});
+ }
+ elsif ($type eq 'xref' or $type eq 'inforef')
+ {
+ return &$I('See %{reference_name}', { 'reference_name' => $name
},{'duplicate'=>1});
+ }
+ elsif ($type eq 'ref')
+ {
+ return &$I('%{reference_name}', { 'reference_name' => $name
},{'duplicate'=>1});
+ }
+ }
+ return '';
+}
+
+sub html_teletyped_in_stack($)
+{
+ my $stack = shift;
+ foreach my $element(reverse(@$stack))
+ {
+ return 1 if ($complex_format_map->{$element} and
+ $complex_format_map->{$element}->{'style'} and
+ $complex_format_map->{$element}->{'style'} eq 'code');
+ }
+ return 0;
+}
+
+# text after @item in table, vtable and ftable
+sub html_default_table_item($$$$$$$)
+{
+ my $text = shift;
+ my $index_label = shift;
+ my $format = shift;
+ my $command = shift;
+# my $formatted_command = shift;
+ my $style_stack = shift;
+# my $text_formatted = shift;
+# my $text_formatted_leading_spaces = shift;
+# my $text_formatted_trailing_spaces = shift;
+ my $item_cmd = shift;
+ my $formatted_index_entry = shift;
+
+# if (defined($text_formatted) and !exists
$special_list_commands{$format}->{$command})
+# {
+# $text = $text_formatted_leading_spaces . $text_formatted
.$text_formatted_trailing_spaces;
+# }
+# $formatted_command = '' if (!defined($formatted_command) or
+# exists($special_list_commands{$format}->{$command}));
+ if (html_teletyped_in_stack($style_stack))
+ {
+# $text .= '</tt>';
+# $formatted_command = '<tt>' . $formatted_command;
+ $text = '<tt>' . $text . '</tt>';
+ }
+ $text .= "\n" . $index_label if (defined($index_label));
+# return '<dt>' . $formatted_command . $text . '</dt>' . "\n";
+ return '<dt>' . $text . '</dt>' . "\n";
+}
+
+# format text on the line following the @item line (in table, vtable and
ftable)
+sub html_default_table_line($$$)
+{
+ my $text = shift;
+ my $only_inter_item_commands = shift;
+ my $before_items = shift;
+
+ $only_inter_item_commands = '' if (!defined($only_inter_item_commands));
+
+ if ($text =~ /\S/)
+ {
+ return '<dd>' . $text . '</dd>' . "\n";# unless
($only_inter_item_commands);
+ #return $text; # invalid without dd in ul
+ }
+ return '';
+}
+
+#my $cell_nr = -1;
+
+# row in multitable
+sub html_default_row($$$$$$$$)
+{
+ my $text = shift;
+ my $macro = shift;
+ my $columnfractions = shift;
+ my $prototype_row = shift;
+ my $prototype_lengths = shift;
+ my $column_number = shift;
+ my $only_inter_item_commands = shift;
+ my $before_items = shift;
+
+ $only_inter_item_commands = '' if (!defined($only_inter_item_commands));
+
+ # this is used to keep the cell number
+ $html_default_multitable_stack[-1]->[0] = -1;
+
+ if ($text =~ /\S/)
+ {
+ if ($macro eq 'headitem')
+ {
+ return '<thead><tr>' . $text . '</tr></thead>' . "\n";
+ }
+ return '<tr>' . $text . '</tr>' . "\n";
+ }
+ return '';
+}
+
+# cell in multitable
+sub html_default_cell($$$$$$$$)
+{
+ my $text = shift;
+ my $row_macro = shift;
+ my $columnfractions = shift;
+ my $prototype_row = shift;
+ my $prototype_lengths = shift;
+ my $column_number = shift;
+ my $only_inter_item_commands = shift;
+ my $before_items = shift;
+
+ $only_inter_item_commands = '' if (!defined($only_inter_item_commands));
+
+ $html_default_multitable_stack[-1]->[0]++;
+ my $cell_nr = $html_default_multitable_stack[-1]->[0];
+ my $fractions = '';
+
+ if (defined($columnfractions) and (ref($columnfractions) eq 'ARRAY')
+ and exists($columnfractions->[$cell_nr]))
+ {
+ my $fraction = sprintf('%d', 100*$columnfractions->[$cell_nr]);
+ $fractions = " width=\"$fraction%\"";
+ }
+
+ # in constructs like
+ # @strong{
+ # @multitable ....
+ # }
+ # the space won't be removed since the <strong> is put before the space.
+ $text =~ s/^\s*//;
+ $text =~ s/\s*$//;
+
+ if ($row_macro eq 'headitem')
+ {
+ return "<th${fractions}>" . $text . '</th>';
+ }
+ return "<td${fractions}>" . $text . '</td>';
+}
+
+sub html_default_format_list_item_texi($$$$$)
+{
+ my $format = shift;
+ my $line = shift;
+ my $prepended = shift;
+ my $command = shift;
+ my $number = shift;
+
+ my $result_line;
+ my $open_command = 0;
+ if (defined($command) and $command ne '' and !exists
$special_list_commands{$format}->{$command} and $format ne 'itemize')
+ {
+ address@hidden
+ $open_command = 1;
+ $line =~ s/^\s*//;
+ $line =~ s/\s*$//;
+ if (exists ($style_map{$command}))
+ {
+ $result_line = "address@hidden";
+ }
+ elsif (exists ($things_map{$command}))
+ {
+ $result_line = "address@hidden $line\n";
+ }
+ else
+ {
+ $result_line = "address@hidden $line\n";
+ }
+ }
+ elsif (defined($prepended) and $prepended ne '')
+ {
+ $prepended =~ s/^\s*//;
+ $prepended =~ s/\s*$//;
+ $line =~ s/^\s*//;
+ $result_line = $prepended . ' ' . $line;
+ }
+ return ($result_line, $open_command);
+}
+
+
+# format an item in a list
+#
+# argument:
+# text of the item
+# format of the list (itemize or enumerate)
+# command passed as argument to the format
+# formatted_command leading command formatted, if it is a thing command
+sub html_default_list_item($$$$$$$$$$$)
+{
+ my $text = shift;
+ my $format = shift;
+ my $command = shift;
+ my $formatted_command = shift;
+ my $item_nr = shift;
+ my $enumerate_style = shift;
+ my $number = shift;
+ my $prepended = shift;
+ my $prepended_formatted = shift;
+ my $only_inter_item_commands = shift;
+ my $before_items = shift;
+
+ $only_inter_item_commands = '' if (!defined($only_inter_item_commands));
+
+ $formatted_command = '' if (!defined($formatted_command) or
+ exists($special_list_commands{$format}->{$command}));
+ my $prepend = '';
+# if (defined($prepended) and $prepended ne '')
+# {
+# $prepend = $prepended;
+# }
+# elsif ($formatted_command ne '')
+ if ($formatted_command ne '')
+ {
+ $prepend = $formatted_command;
+ }
+ if ($text =~ /\S/)
+ {
+ return '<li>' . $prepend . $text . '</li>';
+ }
+ return '';
+}
+
+sub html_default_table_list($$$$$$$$$)
+{
+ my $format_command = shift;
+ my $text = shift;
+ my $command = shift;
+ my $formatted_command = shift;
+# enumerate
+ my $item_nr = shift;
+ my $enumerate_style = shift;
+# itemize
+ my $prepended = shift;
+ my $prepended_formatted = shift;
+# multitable
+ my $columnfractions = shift;
+ my $prototype_row = shift;
+ my $prototype_lengths = shift;
+ my $column_number = shift;
+# my $number = shift;
+ $formatted_command = '' if (!defined($formatted_command) or
+ exists($special_list_commands{$format}->{$command}));
+ if ($format_command eq 'itemize')
+ {
+ return "<ul>\n" . $text . "</ul>\n" if (($command eq 'bullet') or
(($command eq '') and ($prepended eq '')));
+ return "<ul$NO_BULLET_LIST_ATTRIBUTE>\n" . $text . "</ul>\n";
+ }
+ elsif ($format_command eq 'multitable')
+ {
+ pop @html_default_multitable_stack;
+ return &$format('multitable', 'table', $text);
+ }
+}
+
+# an html comment
+sub html_default_comment($)
+{
+ my $text = shift;
+ $text =~ s/--+/-/go;
+ return '<!-- ' . $text . ' -->' . "\n";
+}
+
+sub html_begin_style($$;$)
+{
+ my $command = shift;
+ my $text = shift;
+ my $map_ref = shift;
+ my $attribute = t2h_get_attribute($command,$map_ref);
+ $attribute = "<$attribute>" if ($attribute ne '');
+ return $attribute.$text;
+}
+
+sub html_end_style($$;$)
+{
+ my $command = shift;
+ my $text = shift;
+ my $map_ref = shift;
+ my $attribute = t2h_get_attribute($command,$map_ref);
+ if ($attribute =~ /^(\w+)/)
+ {
+ $attribute = $1;
+ }
+ $attribute = "</$attribute>" if ($attribute ne '');
+ return $text.$attribute;
+}
+
+# a paragraph
+# arguments:
+# $text of the paragraph
+# $align for the alignement
+# $indent for the indent style (indent or noindent)
+# The following is usefull if the paragraph is in an itemize.
+# $paragraph_command is the leading formatting command (like @minus)
+# $paragraph_command_formatted is the leading formatting command formatted
+# $paragraph_number is a reference on the number of paragraphs appearing
+# in the format. The value should be increased if a paragraph is done
+# $format is the format name (@itemize)
+sub html_default_paragraph($$$$$$$$$$$$)
+{
+ my $text = shift;
+ my $align = shift;
+ my $indent = shift;
+ my $paragraph_command = shift;
+ my $paragraph_command_formatted = shift;
+ my $paragraph_number = shift;
+ my $format = shift;
+ my $item_nr = shift;
+ my $enumerate_style = shift;
+ my $number = shift;
+ my $command_stack_at_end = shift;
+ my $command_stack_at_begin = shift;
+#print STDERR "format: $format\n" if (defined($format));
+#print STDERR "paragraph @$command_stack_at_end; @$command_stack_at_begin\n";
+# $paragraph_command_formatted = '' if
(!defined($paragraph_command_formatted) or
+# exists($special_list_commands{$format}->{$paragraph_command}));
+ return '' if ($text =~ /^\s*$/);
+
+ foreach my $style(t2h_collect_styles($command_stack_at_begin))
+ {
+ $text = html_begin_style($style, $text);
+ }
+ foreach my $style(t2h_collect_styles($command_stack_at_end))
+ {
+ $text = html_end_style($style, $text);
+ }
+
+ if (defined($paragraph_number) and defined($$paragraph_number))
+ {
+ $$paragraph_number++;
+ return $text if (($format eq 'itemize' or $format eq 'enumerate') and
+ ($$paragraph_number == 1));
+ }
+
+ my $top_stack = '';
+ $top_stack = $command_stack_at_begin->[-1] if (scalar
(@$command_stack_at_begin));
+ if ($top_stack eq 'multitable')
+ {
+ $html_default_multitable_stack[-1]->[1]++;
+ if ($html_default_multitable_stack[-1]->[1] == 0)
+ {
+ return $text;
+ }
+ }
+
+ my $open = '<p>';
+ if ($align)
+ {
+ $open = "<p align=\"$paragraph_style{$align}\">";
+ }
+ return $open.$text.'</p>';
+}
+
+# a preformatted region
+# arguments:
+# $text of the preformatted region
+# $pre_style css style
+# $class identifier for the preformatted region (example, menu-comment)
+# The following is usefull if the preformatted is in an itemize.
+# $leading_command is the leading formatting command (like @minus)
+# $leading_command_formatted is the leading formatting command formatted
+# $preformatted_number is a reference on the number of preformatteds appearing
+# in the format. The value should be increased if a preformatted is done
+sub html_default_preformatted($$$$$$$$$$$$)
+{
+ my $text = shift;
+ my $pre_style = shift;
+ my $class = shift;
+ my $leading_command = shift;
+ my $leading_command_formatted = shift;
+ my $preformatted_number = shift;
+ my $format = shift;
+ my $item_nr = shift;
+ my $enumerate_style = shift;
+ my $number = shift;
+ my $command_stack_at_end = shift;
+ my $command_stack_at_begin = shift;
+
+#print STDERR "preformatted @$command_stack_at_end;
@$command_stack_at_begin\n";
+ return '' if ($text eq '');
+ $leading_command_formatted = '' if (!defined($leading_command_formatted)
or
+ exists($special_list_commands{$format}->{$leading_command}));
+ if (defined($preformatted_number) and defined($$preformatted_number))
+ {
+ $$preformatted_number++;
+ }
+ my $top_stack = '';
+ $top_stack = $command_stack_at_begin->[-1] if (scalar
(@$command_stack_at_begin));
+ if ($top_stack eq 'multitable')
+ {
+ $text =~ s/^\s*//;
+ $text =~ s/\s*$//;
+ }
+
+ foreach my $style(t2h_collect_styles($command_stack_at_begin))
+ {
+ $text = html_begin_style($style, $text, \%style_map_pre);
+ }
+ foreach my $style(t2h_collect_styles($command_stack_at_end))
+ {
+ $text = html_end_style($style, $text, \%style_map_pre);
+ }
+ return "<pre class=\"$class\">".$text."</pre>";
+}
+
+# This function formats a heading for an element
+#
+# argument:
+# an element. It is a hash reference for a node or a sectionning command.
+# it may be the wrong one in case of headings.
+# The interesting keys are:
+# 'text': the heading text
+# 'text_nonumber': the heading text without section number
+# 'node': true if it is a node
+# 'level': level of the element. 0 for @top, 1 for chapter, heading,
+# appendix..., 2 for section and so on...
+# 'tag_level': the sectionning element name, raisesections and lowersections
+# taken into account
+sub html_default_element_heading($$$$$$$$$$$$)
+{
+ my $element = shift;
+ my $command = shift;
+ my $texi_line = shift;
+ my $line = shift;
+ my $in_preformatted = shift;
+ my $one_section = shift;
+ my $element_heading = shift;
+ my $first_in_page = shift;
+ my $is_top = shift;
+ my $previous_is_top = shift;
+ my $command_line = shift;
+ my $element_id = shift;
+ my $new_element = shift;
+#print STDERR ":::::::: $element $command i_p $in_preformatted o_s
$one_section e_h $element_heading f_p $first_in_page i_t $is_top p_i_t
$previous_is_top id $element_id new $new_element\n";
+
+ my $result = &$element_label($element_id, $element, $command,
$command_line);
+ if ($new_element and !$one_section)
+ {
+ if (!$element->{'element_ref'}->{'top'})
+ {
+ #return $result if (defined($command) and $command eq 'node' and
!$element_heading);
+ $result .= &$print_element_header($first_in_page, $previous_is_top);
+ }
+ else
+ {
+ $result .= &$print_head_navigation(undef, address@hidden) if
(get_conf('SPLIT') or $SECTION_NAVIGATION);
+ }
+ }
+
+ return $result if (!$element_heading);
+ return $result. &$heading($element, $command, $texi_line, $line,
$in_preformatted, $one_section, $element_heading);
+}
+
+sub html_default_heading($$$$$;$$)
+{
+ my $element = shift;
+ my $command = shift;
+ my $texi_line = shift;
+ my $line = shift;
+ my $in_preformatted = shift;
+ my $one_section = shift;
+ my $element_heading = shift;
+
+ my $level = 3;
+ if (!$element->{'node'})
+ {
+ $level = $element->{'level'};
+ }
+ my $text = $element->{'text'};
+ my $class = $element->{'tag_level'};
+ $class = 'unnumbered' if ($class eq 'top' or $class eq 'centerchap');
+ my $align = '';
+ $align = ' align="center"' if ($element->{'tag'} eq 'centerchap');
+ if ($element->{'top'})
+ {
+ return '' if ($element->{'titlefont'});
+ $level = 1;
+ $text = $Texi2HTML::NAME{'Top'};
+ $class = 'settitle' unless ($one_section);
+ }
+ # when it is a heading, the element is irrelevant, so the command and the
+ # line are used...
+ if (defined($command) and $command =~ /heading/)
+ {
+ $level = $main::sec2level{$command} if
(defined($main::sec2level{$command}));
+ if (defined($line))
+ {
+ $text = $line;
+ # this isn't done in main program in that case...
+ chomp ($text);
+ $text =~ s/^\s*//;
+ }
+ $class = $command;
+ }
+ elsif (defined($element->{'tocid'}) and $TOC_LINKS)
+ {
+ $text = &$anchor ('',
"$Texi2HTML::THISDOC{'toc_file'}#$element->{'tocid'}", $text);
+ }
+ $level = 1 if ($level == 0);
+ return '' if ($text !~ /\S/);
+ if (!$in_preformatted)
+ {
+ return "<h$level class=\"$class\"$align>$text</h$level>\n";
+ }
+ else
+ {
+ return "<strong>$text</strong>\n";
+ }
+}
+
+# formatting of raw regions
+# if L2H is true another mechanism is used for tex
+sub html_default_raw($$;$)
+{
+ my $style = shift;
+ my $text = shift;
+ my $line_nr = shift;
+ my $expanded = 1 if (grep {$style eq $_} @EXPAND);
+ if ($style eq 'verbatim' or $style eq 'verbatiminclude' or ($style eq
'tex' and $expanded))
+ {
+ $style = 'verbatim' if ($style eq 'verbatiminclude');
+ return "<pre class=\"$style\">" . &$protect_text($text) . '</pre>';
+ }
+ elsif ($style eq 'html' and $expanded)
+ {
+ chomp ($text);
+ return $text;
+ }
+ elsif ($expanded)
+ {
+ main::echo_warn ("Raw $style not handled especially, but expanded",
$line_nr);
+ return &$protect_text($text);
+ }
+ else
+ {
+ return '';
+ }
+}
+
+# This function formats a footnote reference and the footnote text associated
+# with a given footnote.
+# The footnote reference is the text appearing in the main document pointing
+# to the footnote text.
+#
+# arguments:
+# absolute number of the footnote (in the document)
+# relative number of the footnote (in the page)
+# identifier for the footnote
+# identifier for the footnote reference in the main document
+# main document file
+# footnote text file
+# array with the footnote text lines
+# the state. See menu entry.
+#
+# returns:
+# reference on an array containing the footnote text lines which should
+# have been updated
+# the text for the reference pointing on the footnote text
+sub html_default_foot_line_and_ref($$$$$$$$$)
+{
+ my $number_in_doc = shift;
+ my $number_in_page = shift;
+ my $footnote_id = shift;
+ my $place_id = shift;
+ my $document_file = shift;
+ my $footnote_file = shift;
+ my $lines = shift;
+ my $document_state = shift;
+
+ if ($document_file eq $footnote_file)
+ {
+ $document_file = $footnote_file = '';
+ }
+ unshift (@$lines, '<h3>' .
+ &$anchor($footnote_id, $document_file . "#$place_id",
+ "($number_in_doc)")
+ . "</h3>\n");
+ # this is a bit obscure, this allows to add an anchor only if formatted
+ # as part of the document.
+ $place_id = '' if ($document_state->{'outside_document'} or
$document_state->{'multiple_pass'});
+ return ($lines, &$anchor($place_id, $footnote_file . "#$footnote_id",
+ "($number_in_doc)"));
+}
+
+# formats a group of footnotes.
+#
+# argument:
+# array reference on the footnotes texts lines
+#
+# returns an array reference on the group of footnotes lines
+sub html_default_foot_section($)
+{
+ my $lines = shift;
+ unshift (@$lines, "<div class=\"footnote\">\n" ,"$DEFAULT_RULE\n", "<h3>"
. &$I('Footnotes') . "</h3>\n");
+ push (@$lines, "</div>\n");
+ return $lines;
+}
+
+sub html_default_image_files($$$$)
+{
+ my $base = shift;
+ my $extension = shift;
+ my $texi_base = shift;
+ my $texi_extension = shift;
+ my @files = ();
+ return @files if (!defined($base) or ($base eq ''));
+ if (defined($extension) and ($extension ne ''))
+ {
+ push @files,["$base.$extension", "$texi_base.$texi_extension"];
+ }
+ foreach my $ext (@IMAGE_EXTENSIONS)
+ {
+ push @files,["$base.$ext", "$texi_base.$ext"];
+ }
+ return @files;
+}
+
+# format an image
+#
+# arguments:
+# image file name with path
+# image basename
+# a boolean true if we are in a preformatted format
+# image file name without path
+# alt text
+# width
+# height
+# raw alt
+# extension
+# path to working dir
+# path to file relative from working dir
+sub html_default_image($$$$$$$$$$$$$$$$$)
+{
+ my $file = shift;
+ my $base = shift;
+ my $preformatted = shift;
+ my $file_name = shift;
+ my $alt = shift;
+ my $width = shift;
+ my $height = shift;
+ my $raw_alt = shift;
+ my $extension = shift;
+ my $working_dir = shift;
+ my $file_path = shift;
+ my $in_paragraph = shift;
+ my $file_locations = shift;
+ my $base_simple_format = shift;
+ my $extension_simple_format = shift;
+ my $file_name_simple_format = shift;
+ my $line_nr = shift;
+
+ if (!defined($file_path) or $file_path eq '')
+ {
+ if (defined($extension) and $extension ne '')
+ {
+ $file = "$base.$extension";
+ }
+ else
+ {
+ $file = "$base.jpg";
+ }
+ main::echo_warn ("no image file for $base, (using $file)", $line_nr);
+ }
+ elsif (! $COMPLETE_IMAGE_PATHS)
+ {
+ $file = $file_name;
+ }
+ $alt = &$protect_text($base) if (!defined($alt) or ($alt eq ''));
+ return "[ $alt ]" if ($preformatted);
+ # it is possible that $file_name is more correct as it allows the user
+ # to chose the relative path.
+ $file = &$protect_text($file);
+ return "<img src=\"$file\" alt=\"$alt\">";
+}
+
+# format a target in the main document for an index entry.
+#
+# arguments:
+# target identifier
+# boolean true if in preformatted format
+# FIXME document the remaining
+sub html_default_index_entry_label($$$$$$$$)
+{
+ my $identifier = shift;
+ my $preformatted = shift;
+ my $entry = shift;
+ my $index_name = shift;
+ my $index_command = shift;
+ my $texi_entry = shift;
+ my $formatted_entry = shift;
+ my $index_entry_ref = shift;
+
+ return '' if (!defined($identifier) or ($identifier !~ /\S/));
+ my $label = &$anchor($identifier);
+ return $label . "\n" if (!$preformatted);
+ return $label;
+}
+
+sub html_default_index_entry_command($$$$$$)
+{
+ my $command = shift;
+ my $index_name = shift;
+ my $label = shift;
+ my $entry_texi = shift;
+ my $entry_formatted = shift;
+ my $index_entry_ref = shift;
+
+ return $label;
+}
+
+# process definition commands line @deffn for example
+sub html_default_def_line($$$$$$$$$$$$$$$$)
+{
+ my $category_prepared = shift;
+ my $name = shift;
+ my $type = shift;
+ my $arguments = shift;
+ my $index_label = shift;
+ my $arguments_array = shift;
+ my $arguments_type_array = shift;
+ my $unformatted_arguments_array = shift;
+ my $command = shift;
+ my $class_name = shift;
+ my $category = shift;
+ my $class = shift;
+ my $style = shift;
+ my $original_command = shift;
+
+ $index_label = '' if (!defined($index_label));
+ chomp($index_label);
+ $category_prepared = '' if (!defined($category_prepared) or
($category_prepared =~ /^\s*$/));
+ $name = '' if (!defined($name) or ($name =~ /^\s*$/));
+ $type = '' if (!defined($type) or $type =~ /^\s*$/);
+ if (!defined($arguments) or $arguments =~ /^\s*$/)
+ {
+ $arguments = '';
+ }
+ else
+ {
+ chomp ($arguments);
+ $arguments = '<i>' . $arguments . '</i>';
+ }
+ my $type_name = '';
+ $type_name = " $type" if ($type ne '');
+ $type_name .= ' <b>' . $name . '</b>' if ($name ne '');
+ $type_name .= $arguments;
+ if (! $DEF_TABLE)
+ {
+ return '<dt>'. $index_label. '<u>' . $category_prepared . ':</u>' .
$type_name . "</dt>\n";
+ }
+ else
+ {
+ return "<tr><td align=\"left\">" . $type_name .
+ "</td><td align=\"right\">" . $category_prepared . $index_label .
"</td></tr>\n";
+ }
+}
+
+# a cartouche
+sub html_default_cartouche($$)
+{
+ my $text = shift;
+
+ if ($text =~ /\S/)
+ {
+ return "<table class=\"cartouche\" border=\"1\"><tr><td>\n" . $text .
"</td></tr></table>\n";
+ }
+ return '';
+}
+
+sub html_default_sp($$)
+{
+ my $number = shift;
+ my $preformatted = shift;
+ return "<br>\n" x $number if (!$preformatted);
+ return "\n" x $number;
+}
+
+sub html_default_acronym_like($$$$$$)
+{
+ my $command = shift;
+ my $acronym_texi = shift;
+ my $acronym_text = shift;
+ my $with_explanation = shift;
+ my $explanation_lines = shift;
+ my $explanation_text = shift;
+ my $explanation_simply_formatted = shift;
+
+ my $attribute = $command;
+ my $opening = "<$attribute>";
+ if (defined($explanation_simply_formatted))
+ {
+ $opening = "<$attribute title=\"$explanation_simply_formatted\">";
+ }
+ if ($with_explanation)
+ {
+ return &$I('%{acronym_like} (%{explanation})', {'acronym_like' =>
$opening . $acronym_text . "</$attribute>", 'explanation' =>
$explanation_text},{'duplicate'=>1})
+ }
+ else
+ {
+ return $opening . $acronym_text . "</$attribute>";
+ }
+}
+
+sub html_default_quotation($$$$)
+{
+ my $command = shift;
+ my $text = shift;
+ my $argument_text = shift;
+ my $argument_text_texi = shift;
+ my $class_text = '';
+ $class_text = " class=\"$command\"" if ($command ne 'quotation');
+ return "<blockquote$class_text>" . $text . "</blockquote>\n";
+}
+
+# format the text within a paragraph style format,
+#
+# argument:
+# format name
+# text within the format
+sub html_default_paragraph_style_command($$)
+{
+ my $format = shift;
+ my $text = shift;
+ return $text;
+}
+
+# format a whole index
+#
+# argument:
+# index text
+# index name
+sub html_default_print_index($$)
+{
+ my $text = shift;
+ my $name = shift;
+ return '' if (!defined($text));
+ return "<table border=\"0\" class=\"index-$name\">\n" .
+ "<tr><td></td><th align=\"left\">" . &$I('Index Entry') . "</th><th
align=\"left\"> " . &$I('Section') . "</th></tr>\n"
+ . "<tr><td colspan=\"3\"> $DEFAULT_RULE</td></tr>\n" . $text .
+ "</table>\n";
+}
+
+# format a letter entry in an index page. The letter entry contains
+# the index entries for the words beginning with that letter. It is
+# a target for links pointing from the summary of the index.
+#
+# arguments:
+# the letter
+# identifier for the letter entry. This should be used to make the target
+# identifier
+# text of the index entries
+sub html_default_index_letter($$$)
+{
+ my $letter = shift;
+ my $id = shift;
+ my $text = shift;
+ return '<tr><th>' . &$anchor($id,'',&$protect_text($letter)) .
+ "</th><td></td><td></td></tr>\n" . $text .
+ "<tr><td colspan=\"3\"> $DEFAULT_RULE</td></tr>\n";
+}
+
+# format an index entry (in a letter entry).
+#
+# arguments:
+# href to the main text, linking to the place where the index entry appears
+# entry text
+# href to the main text, linking to the section or node where the index
+# entry appears
+# section or node heading
+sub html_default_index_entry($$$$$$$$$)
+{
+ my $text_href = shift;
+ my $entry = shift;
+ my $element_href = shift;
+ my $element_text = shift;
+ my $entry_file = shift;
+ my $current_element_file = shift;
+ my $entry_target = shift;
+ my $entry_element_target = shift;
+ my $index_entry_ref = shift;
+
+ return '<tr><td></td><td valign="top">' . &$anchor('', $text_href, $entry)
+ . '</td><td valign="top">' . &$anchor('', $element_href, $element_text)
+ . "</td></tr>\n";
+}
+
+
+sub html_default_copying_comment($$$$)
+{
+ my $copying_lines = shift;
+ my $copying_text = shift;
+ my $copying_no_texi = shift;
+ my $copying_simple_text = shift;
+ return '' if ($copying_no_texi eq '');
+ my $text = &$comment($copying_no_texi);
+ return $text;
+}
+
+# return value is currently ignored
+sub html_default_documentdescription($$$$)
+{
+ my $decription_lines = shift;
+ my $description_text = shift;
+ my $description_no_texi = shift;
+ my $description_simple_text = shift;
+
+ if (defined($DOCUMENT_DESCRIPTION))
+ {
+ $Texi2HTML::THISDOC{'DOCUMENT_DESCRIPTION'} = $DOCUMENT_DESCRIPTION;
+ return $DOCUMENT_DESCRIPTION;
+ }
+
+ #return '' if ($description_no_texi eq '');
+ #my @documentdescription = split (/\n/, $description_no_texi);
+ if ($description_simple_text eq '')
+ {
+ $Texi2HTML::THISDOC{'DOCUMENT_DESCRIPTION'} = undef;
+ return undef;
+ }
+ my @documentdescription = split (/\n/, $description_simple_text);
+ my $document_description = shift @documentdescription;
+ chomp $document_description;
+ foreach my $line (@documentdescription)
+ {
+ chomp $line;
+ $document_description .= ' ' . $line;
+ }
+ $Texi2HTML::THISDOC{'DOCUMENT_DESCRIPTION'} = $document_description;
+ return $document_description;
+}
+
+# format an index summary. This is a list of letters linking to the letter
+# entries.
+#
+# arguments:
+# array reference containing the formatted alphabetical letters
+# array reference containing the formatted non lphabetical letters
+sub html_default_index_summary($$)
+{
+ my $alpha = shift;
+ my $nonalpha = shift;
+
+ my $join = '';
+ my $nonalpha_text = '';
+ my $alpha_text = '';
+ $join = " \n<br>\n" if (@$nonalpha and @$alpha);
+ if (@$nonalpha)
+ {
+ $nonalpha_text = join("\n \n", @$nonalpha) . "\n";
+ }
+ if (@$alpha)
+ {
+ $alpha_text = join("\n \n", @$alpha) . "\n \n";
+ }
+ return "<table><tr><th valign=\"top\">" . &$I('Jump to') .":
</th><td>" .
+ $nonalpha_text . $join . $alpha_text . "</td></tr></table>\n";
+}
+
+sub html_default_element_label($$$$)
+{
+ my $id = shift;
+ my $element = shift;
+ my $command = shift;
+ my $line = shift;
+
+ return &$anchor($id) . "\n";
+}
+
+sub html_default_misc_element_label($$)
+{
+ my $id = shift;
+ my $misc_page_name = shift;
+ return &$anchor($id) . "\n";
+}
+
+sub html_default_anchor_label($$$)
+{
+ my $id = shift;
+ my $anchor_text = shift;
+ my $anchor_reference = shift;
+ return &$anchor($id);
+}
+
+sub html_default_tab_item_texi($$$$$$)
+{
+ my $command = shift;
+ my $commands_stack = shift;
+ my $stack = shift;
+ my $state = shift;
+ my $line = shift;
+ my $line_nr = shift;
+
+ if (defined($commands_stack) and @$commands_stack and $commands_stack->[-1]
eq 'multitable' and @html_default_multitable_stack)
+ {
+ $html_default_multitable_stack[-1]->[1] = -1;
+ }
+ return undef;
+}
+
+sub html_default_line_command($$$$)
+{
+ my $command = shift;
+ my $arg_text = shift;
+ my $arg_texi = shift;
+ my $state = shift;
+
+ return '' if ($arg_text eq '');
+ my $style = $line_command_map{$command};
+ if ($style)
+ {
+ my $attribute_text = '';
+ if ($style =~ /^(\w+)(\s+.*)/)
+ {
+ $style = $1;
+ $attribute_text = $2;
+ }
+ $arg_text = "<${style}$attribute_text>$arg_text</$style>";
+ }
+ $arg_text .= "<br>" if ($command eq 'author');
+ $arg_text .= "\n";
+ $arg_text .= "$DEFAULT_RULE\n" if ($command eq 'title');
+ return $arg_text;
+}
+
+1;
Index: formats/info.init
===================================================================
RCS file: formats/info.init
diff -N formats/info.init
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ formats/info.init 22 May 2009 18:50:30 -0000 1.1
@@ -0,0 +1,3183 @@
+#+##############################################################################
+#
+# info.init: convert to info
+#
+# Copyright (C) 2008, 2009 Patrice Dumas <address@hidden>
+#
+# 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 2 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, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA
+#
+#-##############################################################################
+
+use Data::Dumper;
+
+use strict;
+
+$Data::Dumper::Maxdepth = 12;
+
+sub info_default_load();
+
+if ($DEFAULT_OUTPUT_FORMAT eq 'info')
+{
+ info_default_load();
+}
+
+my %info_default_indented_commands;
+my %info_default_format;
+my %info_default_enable_encoding_accents;
+my @simple_quoted_commands;
+my @asis_commands;
+my @chevron_commands;
+my %info_default_accent_commands = ();
+my %info_default_leaf_command = ();
+my @info_default_normal_formats;
+my $info_default_end_sentence_character;
+my $info_default_after_punctuation_characters;
+my $info_default_indent_length;
+my %info_default_indent_format_length;
+my %default_info_level_to_symbol;
+my $info_default_index_length_to_node;
+my $info_default_listoffloat_caption_entry_length;
+my $info_default_listoffloat_append;
+
+sub info_default_load()
+{
+
+$USE_NODES = 1;
+$USE_SECTIONS = 0;
address@hidden = ('info', 'direntry');
+$EXTENSION = 'info';
+$SHOW_MENU = 1;
+$USE_SETFILENAME = 1;
+$IGNORE_BEFORE_SETFILENAME = 1;
+$NODE_NAME_IN_MENU = 1;
+$SPLIT_INDEX = 0;
+$FOOTNOTESTYLE = 'end';
+$INLINE_CONTENTS = 1;
+$INLINE_INSERTCOPYING = 1;
+$SIMPLE_MENU = 1;
+$MENU_SYMBOL = '*';
+$USE_MENU_DIRECTIONS = 0;
+$USE_UP_FOR_ADJACENT_NODES = 0;
+$USE_ISO = 0;
+$ENABLE_ENCODING_USE_ENTITY = 0;
+$ENABLE_ENCODING = 1;
address@hidden = ('png', 'jpg', 'txt');
+$CAPTION_STYLE = 'asis';
+$DEFAULT_ENCODING = 'ascii';
+
+
+$no_paragraph_commands{'anchor'} = 1;
+
+%simple_map = %ascii_simple_map;
+%simple_map_pre = %simple_map;
+%simple_map_texi = %simple_map;
+
+%things_map = %ascii_things_map;
+%pre_map = %things_map;
+
+$misc_command{'exdent'}->{'keep'} = 1;
+$misc_command{'noindent'}->{'keep'} = 1;
+$misc_command{'indent'}->{'keep'} = 1;
+
+%line_command_map = (
+ 'dircategory' => ''
+);
+
+# sc and var upcase.
address@hidden = ('cite', 'code', 'command', 'env', 'file', 'kbd',
+ 'option', 'samp');
+# slanted?
address@hidden = ('asis', 'b', 'ctrl', 'dmn', 'i', 'math', 'sc', 't', 'r',
+ 'slanted', 'var', 'titlefont', 'verb', 'clickstyle');
address@hidden = ('key', 'indicateurl');
+
+%info_default_accent_commands = ();
+
+foreach my $accent_command ('tieaccent', 'dotless', keys(%unicode_accents),
keys(%accent_map))
+{
+ $info_default_accent_commands{$accent_command} = 1;
+ $style_map{$accent_command} = { 'function' => \&info_default_accent };
+}
+
+foreach my $command (keys(%style_map))
+{
+ delete $style_map{$command}->{'attribute'} if
(exists($style_map{$command}->{'attribute'}));
+ delete $style_map{$command}->{'quote'} if
(exists($style_map{$command}->{'quote'}));
+ if (grep {$_ eq $command} @simple_quoted_commands)
+ {
+ delete $style_map{$command}->{'function'} if
(exists($style_map{$command}->{'function'}));
+ $style_map{$command}->{'begin'} = '`';
+ $style_map{$command}->{'end'} = "'";
+ next;
+ }
+ elsif (grep {$_ eq $command} @asis_commands)
+ {
+ delete $style_map{$command}->{'function'} if
(exists($style_map{$command}->{'function'}));
+ delete $style_map{$command}->{'begin'} if
(exists($style_map{$command}->{'begin'}));
+ delete $style_map{$command}->{'end'} if
(exists($style_map{$command}->{'end'}));
+ }
+ if (grep {$_ eq $command} @chevron_commands)
+ {
+ delete $style_map{$command}->{'function'} if
(exists($style_map{$command}->{'function'}));
+ $style_map{$command}->{'begin'} = '<';
+ $style_map{$command}->{'end'} = '>';
+ next;
+ }
+}
+
+$style_map{'strong'}->{'begin'} = '*';
+$style_map{'strong'}->{'end'} = '*';
+$style_map{'dfn'}->{'begin'} = '"';
+$style_map{'dfn'}->{'end'} = '"';
+$style_map{'emph'}->{'begin'} = '_';
+$style_map{'emph'}->{'end'} = '_';
+
+
+%info_default_leaf_command = ();
+foreach my $command ('uref', 'url', 'email', 'click')
+{
+ $info_default_leaf_command{$command} = 1;
+ if (defined ($style_map{$command}->{'args'}))
+ {
+ $style_map{$command}->{'orig_args'} = [
@{$style_map{$command}->{'args'}} ];
+ }
+ else
+ {
+ $style_map{$command}->{'orig_args'} = [ 'normal' ];
+ }
+ $style_map{$command}->{'args'} = [];
+ foreach my $arg (@{$style_map{$command}->{'orig_args'}})
+ {
+ push @{$style_map{$command}->{'args'}}, 'keep';
+ }
+}
+
+$style_map{'uref'}->{'function'} = \&info_default_uref;
+$style_map{'url'}->{'function'} = \&info_default_uref;
+$style_map{'email'}->{'function'} = \&info_default_email;
+
+foreach my $command (keys(%style_map))
+{
+ $style_map_pre{$command} = {};
+ $style_map_texi{$command} = {};
+ foreach my $key (keys(%{$style_map{$command}}))
+ {
+ $style_map_pre{$command}->{$key} = $style_map{$command}->{$key};
+ $style_map_texi{$command}->{$key} = $style_map{$command}->{$key};
+ }
+}
+
+$special_list_commands{'itemize'} = {};
address@hidden = ('table', 'vtable', 'ftable', 'enumerate',
+ 'itemize');
+foreach my $format (@info_default_normal_formats, 'group', 'cartouche')
+{
+ $format_map{$format} = '';
+}
+
+foreach my $command (keys (%{$complex_format_map}),
@info_default_normal_formats, 'quotation', 'deff_item', 'deff_itemx')
+{
+ $info_default_indented_commands{$command} = 1;
+}
+
+foreach my $command (keys(%info_default_indented_commands), 'multitable',
'float', 'menu', 'flushright', 'flushleft', 'center')
+{
+ $info_default_format{$command} = 1;
+}
+
+foreach my $non_indented_command('format', 'smallformat', 'menu',
+ 'detailmenu', 'direntry')
+{
+ $info_default_indented_commands{$non_indented_command} = 0;
+}
+
+$info_default_end_sentence_character = quotemeta($punctuation_characters);
+$info_default_after_punctuation_characters =
quotemeta($after_punctuation_characters);
+$info_default_indent_length = 5;
+
+%info_default_indent_format_length = ('enumerate' => 2,
+ 'itemize' => 3,
+ 'table' => 0,
+ 'vtable' => 0,
+ 'ftable' => 0,
+ );
+
+%default_info_level_to_symbol = (
+ 0 => '*',
+ 1 => '*',
+ 2 => '=',
+ 3 => '-',
+ 4 => '.'
+);
+
+$info_default_index_length_to_node = 41;
+
+$info_default_listoffloat_caption_entry_length = 41;
+$info_default_listoffloat_append = '...: ';
+
+push @command_handler_init, \&info_default_init_accent_enable_encoding;
+push @command_handler_init, \&info_default_init_variables;
+
+
+$style = \&info_default_style;
+$print_page_head = \&info_default_print_page_head;
+$toc_body = \&info_default_noop;
+$about_body = \&info_default_noop;
+$print_Footnotes = \&info_default_noop;
+$copying_comment = \&info_default_copying_comment;
+$element_heading = \&info_default_element_heading;
+$heading = \&info_default_heading;
+$normal_text = \&info_default_normal_text;
+$paragraph = \&info_default_paragraph;
+$preformatted = \&info_default_preformatted;
+$empty_preformatted = \&info_default_preformatted;
+$empty_line = \&info_default_empty_line;
+# maybe should not be called from the main program?
+$print_page_foot = \&info_default_print_page_foot;
+$print_Top_footer = \&info_default_print_Top_footer;
+$print_Top = \&info_default_print_section;
+$print_section = \&info_default_print_section;
+$end_section = \&info_default_end_section;
+$one_section = \&info_default_one_section;
+$begin_format_texi = \&info_default_begin_format_texi;
+$begin_style_texi = \&info_default_begin_style_texi;
+$begin_paragraph_texi = \&info_default_begin_paragraph_texi;
+$simple_command = \&info_default_simple_command;
+$thing_command = \&info_default_thing_command;
+$begin_special_region = \&info_default_begin_special_region;
+$end_special_region = \&info_default_end_special_region;
+$anchor_label = \&info_default_anchor_label;
+$element_label = \&info_default_noop;
+$menu_link = \&info_default_menu_link;
+$menu_command = \&info_default_menu_command;
+$complex_format = \&info_default_complex_format;
+$quotation = \&info_default_quotation;
+$unknown = \&info_default_misc_commands;
+$external_ref = \&info_default_external_ref;
+$internal_ref = \&info_default_internal_ref;
+$image = \&info_default_image;
+$image_files = \&info_default_image_files;
+$index_summary = \&info_default_index_summary;
+$summary_letter = \&info_default_summary_letter;
+$index_entry = \&info_default_index_entry;
+$index_letter = \&info_default_index_letter;
+$print_index = \&info_default_print_index;
+$index_entry_label = \&info_default_index_entry_label;
+$foot_section = \&info_default_foot_lines;
+$foot_line_and_ref = \&info_default_foot_line_and_ref;
+$footnote_texi = \&info_default_footnote_texi;
+$list_item = \&info_default_list_item;
+$format_list_item_texi = \&info_default_format_list_item_texi;
+$format = \&info_default_format;
+$tab_item_texi = \&info_default_tab_item_texi;
+$acronym_like = \&info_default_acronym_like;
+$sp = \&info_default_sp;
+$paragraph_style_command = \&info_default_paragraph_style_command;
+$cell = \&info_default_cell;
+$row = \&info_default_row;
+$table_list = \&info_default_table_list;
+$def_item = \&info_default_def_item;
+$def = \&info_default_def;
+$def_line = \&info_default_def_line;
+$float = \&info_default_float;
+$listoffloats_entry = \&info_default_listoffloats_entry;
+$listoffloats = \&info_default_listoffloats;
+$colon_command = \&info_default_colon_command;
+$raw = \&info_default_raw;
+$line_command = \&info_default_line_command;
+$element_file_name = \&info_default_element_file_name;
+
+}
+
+#Â FIXME initialize
+my %info_default_state_map = ();
+my $info_default_out_file_nr = 1;
+my $info_default_dir_specification = '';
+my @info_default_pending_indirect = ();
+my @info_default_pending_footnotes = ();
+my $info_default_state_nr = 0;
+
+my %info_default_index_line_string_length = ();
+my %info_default_index_entries = ();
+my $info_default_footnote_index = 0;
+my $info_default_current_node = undef;
+
+sub info_default_init_variables()
+{
+ %info_default_state_map = ();
+ $info_default_out_file_nr = 1;
+ $info_default_dir_specification = '';
+ @info_default_pending_indirect = ();
+ @info_default_pending_footnotes = ();
+ $info_default_state_nr = 0;
+
+ %info_default_index_line_string_length = ();
+ %info_default_index_entries = ();
+ $info_default_footnote_index = 0;
+ $info_default_current_node = undef;
+}
+
+#Â this is put in command_handler_init such that it sets things right
+#Â in case $ENABLE_ENCODING is set and haslead to modification of the
+#Â accent functions
+sub info_default_init_accent_enable_encoding()
+{
+ return unless ($ENABLE_ENCODING);
+ foreach my $key (keys(%unicode_accents), 'dotless')
+ {
+ $info_default_enable_encoding_accents{$key} = 1;
+ $t2h_enable_encoding_default_accent{'normal'}->{$key} =
\&t2h_default_ascii_accent;
+ $t2h_enable_encoding_default_accent{'texi'}->{$key} =
\&t2h_default_ascii_accent;
+ $t2h_enable_encoding_default_accent{'pre'}->{$key} =
\&t2h_default_ascii_accent;
+ $style_map{$key}->{'function'} = \&info_default_accent;
+ $style_map_texi{$key}->{'function'} = \&info_default_accent;
+ $style_map_pre{$key}->{'function'} = \&info_default_accent;
+ }
+}
+
+sub info_default_uref($$)
+{
+ shift;
+ my $args = shift;
+ my $url = shift @$args;
+ my $text = shift @$args;
+ my $replacement = shift @$args;
+ #$url =~ s/\s*$//;
+ #$url =~ s/^\s*//;
+ $url = main::normalise_space($url);
+ $replacement = '' if (!defined($replacement));
+ $replacement = main::normalise_space($replacement);
+ return $replacement if ($replacement ne '');
+ $text = '' if (!defined($text));
+ $text = main::normalise_space($text);
+ return "`$url'" if ($text eq '');
+ return "$text ($url)";
+}
+
+sub info_default_email($$)
+{
+ my $command = shift;
+ my $args = shift;
+ my $mail = shift @$args;
+ my $text = shift @$args;
+ $mail = main::normalise_space($mail);
+ $text = '' if (!defined($text));
+ $text = main::normalise_space($text);
+ $mail = "<$mail>";
+ return $mail unless ($text ne '');
+ return "$text $mail";
+}
+
+
+sub info_default_accent($$$)
+{
+ my @args = @_;
+ my $command = shift;
+ my $args = shift;
+ my $text = $args->[0];
+ my $style_stack = shift;
+ my $state = shift;
+
+ my $result;
+ if ($ENABLE_ENCODING and $info_default_enable_encoding_accents{$command})
+ {
+ $result = &t2h_enable_encoding_normal_accent(@args);
+ }
+ else
+ {
+ $result = &t2h_default_ascii_accent(@args);
+ }
+ if (scalar(@$style_stack) and
$info_default_accent_commands{$style_stack->[-1]})
+ {
+ return $result;
+ }
+ return info_default_store_text($state,$result,'accents_commands');
+# return '' if info_default_store_text($state,$result,'accents_commands');
+# return $result;
+}
+
+sub info_default_noop
+{
+ return '';
+}
+
+sub info_default_copying_comment($$$$)
+{
+ my $copying_lines = shift;
+ my $copying_text = shift;
+ my $copying_no_texi = shift;
+ my $copying_simple_text = shift;
+ return '' if ($copying_text eq '');
+ return $copying_text;
+}
+
+sub info_default_count_lines($;$$)
+{
+ my $text = shift;
+ my $indent_length = shift;
+ my $indentation_done = shift;
+
+ my $blank_line;
+ my $no_indentation = 0;
+
+ if (!defined($indentation_done) or $indentation_done)
+ {
+ $no_indentation = 1;
+ $indent_length = 0;
+ }
+ my @lines = split /^/, $text;
+ # don't accept empty text.
+ @lines = ('') if (address@hidden);
+ my $line_passed = scalar(@lines);
+ $line_passed-- if ($line_passed);
+
+ my $end_of_line = 0;
+ if (($#lines > 1) and !$end_of_line and ($lines[-1] !~ /\S/) and
($lines[-2] !~ /\S/))
+ {
+ $blank_line = 1;
+ }
+ my $last_line = $lines[-1];
+
+ my $indented_text = shift (@lines);
+print STDERR "COUNT info_default_count_lines(i_done $no_indentation, i_l
$indent_length) i_t `$indented_text'\n";
+ foreach my $line (@lines)
+ {
+print STDERR "ZZZZZZZZZZZZZzz `$line'\n";
+ if ($indent_length and $line =~ /\S/)
+ {
+ $indented_text .= ' ' x $indent_length . $line;
+ }
+ else
+ {
+ $indented_text .= $line;
+ }
+ }
+ if (chomp($text))
+ {
+ $line_passed++;
+ $end_of_line = 1;
+ }
+ return ($line_passed, $end_of_line, $last_line, $indented_text,
$blank_line);
+}
+
+sub info_default_get_state($)
+{
+ my $state = shift;
+ if (!exists $info_default_state_map{$state})
+ {
+print STDERR "NEW state $info_default_state_nr\n";
+ my ($current_command, $top_stack);
+ $info_default_state_map{$state} = {};
+ info_default_reset_state($info_default_state_map{$state});
+ #Â since the page head always leave a blank line, and the state may be
+ #Â used for text right after the page head, we set it to 1 here.
+ #Â it may be wrong in other contexts, to be seen.
+ $info_default_state_map{$state}->{'blank_line'} = 1;
+ $info_default_state_map{$state}->{'only_spaces'} = 1;
+ #Â this is the first line, so set to 1. This is reset later in
+ #Â most cases, when a node is seen, but may still be useful in
+ address@hidden, for example
+ $info_default_state_map{$state}->{'line_count'} = 1;
+ $info_default_state_map{$state}->{'nr'} = $info_default_state_nr;
+ $info_default_state_map{$state}->{'state'} = $state;
+ $info_default_state_map{$state}->{'multitable_stack'} = [];
+ @{$info_default_state_map{$state}->{'align_stack'}} =
({'command'=>'normal'});
+ $info_default_state_nr++;
+ }
+print STDERR "RETURN state $state $info_default_state_map{$state}
$info_default_state_map{$state}->{'nr'}\n";
+ return $info_default_state_map{$state};
+}
+
+sub info_default_reset_state($)
+{
+ my $info_state = shift;
+ $info_state->{'top'} = {};
+ $info_state->{'current'} = $info_state->{'top'};
+}
+
+sub info_default_iterator_next($$$)
+{
+ my $current_command = shift;
+ my $command_index = shift;
+ my $command_close = shift;
+print STDERR "NNNNNNNNNNNNNN iterator_next current $current_command idx
$command_index close $command_close\n";
+
+ my $sub_command = $current_command->{'content'}->[$command_index];
+
+ if ($sub_command->{'content'} and !$command_close)
+ {
+ return ($sub_command, 0, 0);
+ }
+
+ if ($current_command->{'content'}->[$command_index+1])
+ {
+ return ($current_command, $command_index+1, 0);
+ }
+ elsif (defined($current_command->{'parent'}))
+ {
+ return ($current_command->{'parent'},
$current_command->{'index_in_parent'}, 1);
+ }
+ else
+ {
+ return (undef, undef, undef);
+ }
+}
+
+sub info_default_next($$$)
+{
+ my $current = shift;
+ my $index = shift;
+ my $close = shift;
+
+ my $text;
+ my $command;
+
+ my ($current_next, $index_next, $close_next) =
info_default_iterator_next($current, $index, $close);
+ return ($current_next, $index_next, $close_next, $text, $command) if
(!defined($current_next));
+
+ my $content = $current_next->{'content'}->[$index_next];
+ $command = $content->{'command'} if (defined($content->{'command'}));
+ if ($close_next)
+ {
+ return ($current_next, $index_next, $close_next, $content->{'end'},
$command);
+ }
+ if (defined($content->{'text'}))
+ {
+ return ($current_next, $index_next, $close_next, $content->{'text'},
$command);
+ }
+ if (defined($content->{'begin'}))
+ {
+ $text = $content->{'begin'};
+ }
+ if (defined($content->{'end'}) and !defined($content->{'content'}))
+ {
+ if (!defined($text))
+ {
+ $text = $content->{'end'};
+ }
+ else
+ {
+ $text .= $content->{'end'};
+ }
+ }
+ return ($current_next, $index_next, $close_next, $text, $command);
+}
+
+
+#Â Beware that there is a pending word if the text doesn't end with
+# a space
+sub info_default_process_text($$$$$$$;$)
+{
+ my $text = shift;
+ my $line_char_counter = shift;
+ my $pending_spaces = shift;
+ my $pending_word = shift;
+ my $indent_length = shift;
+ my $in_para = shift;
+ my $max_column = shift;
+# indentation for the lines except for the first one
+ my $indent_length_next = shift;
+
+ $indent_length_next = $indent_length if (!defined($indent_length_next));
+
+ $indent_length = 0 if (!defined($indent_length));
+
+ my $line_passed = 0;
+ my $result = '';
+
+print STDERR "process_text(indent($indent_length), in_para $in_para spaces
`$pending_spaces') line_char_counter $line_char_counter `$text'\n";
+ if (!$in_para)
+ { #Â should never be in preformatted, but in string processing
+ my $chomped_text = $text;
+ chomp($chomped_text);
+ if ($indent_length > $line_char_counter and $chomped_text ne '')
+ {
+ $text = ' ' x ($indent_length - $line_char_counter) . $text;
+ }
+ $line_char_counter += length($text);
+ if (chomp($chomped_text))
+ {
+ $line_passed = 1;
+ $line_char_counter = 0;
+ }
+ return ($line_char_counter, $pending_spaces, $pending_word,
$line_passed, $text);
+ }
+
+ while ($text ne '')
+ {
+ my $pending_word_text = 'UNDEF';
+$pending_word_text = $pending_word if (defined($pending_word));
+
+#print STDERR "l_c_c $line_char_counter pending_word $pending_word_text,
pending_spaces `$pending_spaces', result `$result'\n";
+ if ($text =~ s/^(\s+)//)
+ {
+ my $new_spaces = $1;
+ #Â in general there are no end of lines in the lines cut. However, it
+ #Â may happen with @* in @def* lines
+ my @lines = split /^/, $new_spaces;
+ my $eol_spaces;
+ if (@lines > 1)
+ {
+ $new_spaces = pop @lines;
+ $eol_spaces = join ("", @lines);
+print STDERR "EOL_SPACES[$line_char_counter](+$pending_spaces)
`$eol_spaces'\n";
+ }
+ if (defined($pending_word))
+ {
+ if ($indent_length > $line_char_counter + length($pending_spaces))
+ {
+ $pending_spaces = ' ' x ($indent_length - $line_char_counter)
. $pending_spaces;
+ }
+ $result .= $pending_spaces . $pending_word;
+ $line_char_counter +=
length($pending_spaces)+length($pending_word);
+ $pending_spaces = $new_spaces;
+ $pending_word = undef;
+ }
+ elsif (!$eol_spaces)
+ {
+ $pending_spaces .= $new_spaces;
+ }
+ if ($eol_spaces)
+ {
+ #$result .= $pending_spaces . $eol_spaces;
+ $result .= $eol_spaces;
+ $line_passed += scalar(@lines);
+ $indent_length = $indent_length_next;
+ $line_char_counter = 0;
+ #$pending_spaces = $new_spaces;
+ $pending_spaces = '';
+ }
+ if (length($pending_spaces) + $line_char_counter > $max_column)
+ {
+ $pending_spaces = '';
+ $result .= "\n";
+ $line_passed++;
+ $indent_length = $indent_length_next;
+ $line_char_counter = 0;
+ }
+ }
+ elsif ($text =~ s/^([^\s]+)//)
+ {
+ my $word = $1;
+ $pending_word = '' if (!defined($pending_word));
+ $pending_word .= $word;
+ # The $line_char_counter != 0 is here to cope with the case of a
+ # word longer than $line_char_counter followed by more letters:
+ #Â a line would be passed each time some text is appended.
+ if ((length($pending_spaces)+length($pending_word) +
$line_char_counter > $max_column) and $line_char_counter != 0)
+ {
+ $pending_spaces = '';
+ $result .= "\n";
+ $line_passed++;
+ $indent_length = $indent_length_next;
+ $line_char_counter = 0;
+ }
+ }
+ }
+ return ($line_char_counter, $pending_spaces, $pending_word, $line_passed,
$result)
+}
+
+sub info_default_skip_spaces($$$)
+{
+ my $current = shift;
+ my $index = shift;
+ my $close = shift;
+
+ print STDERR "SKIP_SPACES\n";
+ while(1)
+ {
+ my ($current_next, $index_next, $close_next) =
info_default_iterator_next($current, $index, $close);
+ return if ($close_next or (!defined($current_next)));
+ my $content = $current_next->{'content'}->[$index_next];
+ if (defined($content->{'begin'}))
+ {
+ $content->{'begin'} =~ s/^\s*//;
+print STDERR "SKIP_SPACES begin\n";
+ return if ($content->{'begin'} ne '');
+ }
+ if (defined($content->{'content'}) or
defined($content->{'format_name'})
+ or $content->{'definition_line'})
+ { #Â non empty commands stop space skipping, even if they contain
+ # only spaces, like @asis{ }
+ #Â also for item(x) that have format_name defined
+print STDERR "SKIP_SPACES command?\n";
+ return;
+ }
+ if (defined($content->{'text'}))
+ {
+print STDERR "SKIP_SPACES text\n";
+ $content->{'text'} =~ s/^\s*//;
+ return if ($content->{'text'} ne '');
+ }
+ if (defined($content->{'end'}))
+ {
+print STDERR "SKIP_SPACES end\n";
+ $content->{'end'} =~ s/^\s*//;
+ return if ($content->{'end'} ne '');
+ }
+ ($current, $index, $close) = ($current_next, $index_next, $close_next);
+ }
+}
+
+sub info_default_store_pending($$$;$)
+{
+ my $line_char_counter = shift;
+ my $pending_spaces = shift;
+ my $pending_word = shift;
+ my $indent_length = shift;
+
+ $indent_length = 0 if (!defined($indent_length));
+ my $indent_text = '';
+ $indent_text = ' ' x $indent_length;
+
+ my $pending_word_text = 'undef';
+ $pending_word_text = $pending_word if (defined($pending_word));
+ print STDERR "store_pending(spaces `$pending_spaces',
indent($indent_length) `$indent_text' word `$pending_word_text'\n";
+ my $result = $pending_spaces;
+ $pending_spaces = '';
+ if (defined($pending_word))
+ {
+ $result .= $pending_word;
+ $pending_word = undef;
+ }
+
+ my $chomped_result = $result;
+ chomp ($chomped_result);
+ if ($line_char_counter == 0 and $chomped_result ne '')
+ {
+ $result = $indent_text . $result;
+ }
+
+ $line_char_counter += length($result);
+ return ($line_char_counter, $pending_spaces, $pending_word, $result);
+}
+
+sub info_default_output($)
+{
+ my $info_state = shift;
+ my $result = '';
+ print STDERR "Storing the stack\n";
+ #print STDERR "" . Data::Dumper->Dump([$info_state->{'top'}]);
+ my ($characters_count, $lines_count);
+ ($characters_count, $result, $lines_count) =
info_default_process_content($info_state->{'top'}, $info_state);
+ $info_state->{'offset_in_file'} += $characters_count;
+ $info_state->{'line_count'} += $lines_count;
+ info_default_reset_state($info_state)
+ if (!defined($info_state->{'current'}->{'command'}));
+ return $result;
+}
+
+
+sub info_default_process_content($$)
+{
+ my $current_command = shift;
+ my $info_state = shift;
+
+ my $length = 0;
+ my $result = '';
+
+ my $line_char_counter = 0;
+ my $all_line_passed = 0;
+
+ my $pending_spaces = '';
+ my $pending_word;
+ my $preformatted = 0;
+ my $indent_level = 0;
+ my $item_pending;
+ my $in_exdent = 0;
+ my $in_para = 0;
+ my $table_item_line = 0;
+ my $in_table_item = 0;
+ my $max_column = get_conf('fillcolumn');
+ my $direntry = 0;
+ my $preformatted_format = 0;
+
+ #Â for formats that needs to process a full line (center and flushright)
+ # to know the line length before outputing
+ my $current_line = undef;
+
+ my ($current, $index, $close) = ($current_command, 0, 0);
+
+ #print STDERR "info_default_process_content: $current_command\n";
+ while(1)
+ {
+ last if (!defined($current));
+ my $content = $current->{'content'}->[$index];
+ my $text_added = '';
+ my $item_line_added = 0;
+ my $indentation_done = 0;
+ my $text_item_pending = '';
+ $text_item_pending = $item_pending if (defined($item_pending));
+ my $text_length = '';
+ $text_length = "$content->{'text'}" if defined($content->{'text'});
+ my $text_command = '';
+ $text_command = $content->{'command'} if defined($content->{'command'});
+ my $in_node_count = 0;
+ $in_node_count = $info_state->{'line_count'} if
defined($info_state->{'line_count'});
+ print STDERR
"($text_command|$text_length|$close|${all_line_passed}+$in_node_count|l_c_cnt
$line_char_counter) prfrmted $preformatted para $in_para indent_lvl
$indent_level in_exdent $in_exdent only_spaces $info_state->{'only_spaces'}
blank_line $info_state->{'blank_line'} table_item_line $table_item_line
in_table_item $in_table_item item_pending $text_item_pending\n";
+ my $pending_word_text = 'undef';
+ $pending_word_text = "`$pending_word'" if (defined($pending_word));
+ print STDERR " spaces: `$pending_spaces' word: $pending_word_text\n";
+
+ my $indent_length = $indent_level * $info_default_indent_length;
+ my $indent_length_next_line;
+ #Â indent_length is also set here for table @item so in that case
+ #Â $info_default_indent_format_length{$item_pending} is not taken
+ #Â into account, luckily it is 0.
+ $indent_length = ($indent_level -1) * $info_default_indent_length
+ if ($indent_level and ($in_exdent or $table_item_line));
+ my $item_indent_length = 0;
+ if ($item_pending)
+ {
+ $indent_length_next_line = $indent_length;
+ $indent_length = ($info_default_indent_format_length{$item_pending}
+ +($indent_level -1)* $info_default_indent_length);
+ }
+
+ if ($close)
+ {
+ if (defined($content->{'end'}))
+ {
+ $text_added .= $content->{'end'};
+ }
+ if ($info_default_indented_commands{$content->{'command'}})
+ {
+ $indent_level--;
+ if ($indent_level > 0 and !$info_state->{'blank_line'} and
$content->{'command'} !~ /^deff_item/ and !$preformatted)
+ {
+ $text_added .= "\n";
+ }
+ #Â this nullify a potential noindent in a random format
+ $info_state->{'indent_para'} = undef;
+ }
+ elsif ($complex_format_map->{$content->{'command'}} or
$content->{'command'} eq 'cartouche')
+ {
+ if (!$info_state->{'blank_line'} and
$info_state->{'only_spaces'} and ($indent_level > 0) and !$preformatted)
+ {
+ $text_added .= "\n";
+ }
+ }
+ if ($complex_format_map->{$content->{'command'}} and
$content->{'content'})
+ {
+ $preformatted_format--;
+ }
+ if ($content->{'command'} eq 'paragraph' and
$info_state->{'align_stack'}->[-1]->{'command'} eq 'normal')
+ {
+ #Â if there is no space at the end of a paragraph, there may be
+ #Â pending text, for example, if there is an ending line like
+ #Â Some address@hidden a comment
+ my $pending;
+ ($line_char_counter, $pending_spaces, $pending_word, $pending) =
info_default_store_pending($line_char_counter, $pending_spaces, $pending_word,
$indent_length);
+ $text_added .= $pending if (defined($pending));
+ $text_added =~ s/\s*$//;
+ $pending_spaces = '';
+ $in_para = 0;
+ $info_state->{'indent_para'} = undef;
+ $text_added .= "\n" unless (($line_char_counter +
length($text_added)) == 0);
+ }
+ elsif ($content->{'command'} eq 'preformatted')
+ {
+ #Â if preformatted doesn't end with a newline, it is added here
+ $text_added .= "\n" unless ($line_char_counter == 0);
+ $preformatted--;
+ }
+ elsif ($content->{'command'} eq 'menu')
+ {
+ $text_added .= "\n" unless ($info_state->{'blank_line'});
+ }
+ elsif ($content->{'command'} eq 'float')
+ {
+ $text_added = "\n" . $text_added unless
($info_state->{'blank_line'});
+ }
+ elsif ($paragraph_style{$content->{'command'}})
+ {
+ my $popped = pop @{$info_state->{'align_stack'}};
+ print STDERR "BUG: align_stack, popped $popped->{'command'} ne
command $content->{'command'}\n" if ($popped->{'command'} ne
$content->{'command'});
+ }
+ elsif ($content->{'command'} eq 'multitable')
+ {
+ my $multitable = pop @{$info_state->{'multitable_stack'}};
+ $max_column = $multitable->{'max_column_kept'};
+ $result = $multitable->{'result_kept'};
+ $line_char_counter = $multitable->{'line_char_counter_kept'};
+ $all_line_passed = $multitable->{'all_line_passed_kept'};
+ $length = $multitable->{'length_kept'};
+ $info_state->{'offset_in_file'} =
$multitable->{'offset_in_file_kept'};
+ $info_state->{'line_count'} = $multitable->{'line_count_kept'};
+ print STDERR "MULTITABLE close, lines:
$multitable->{'line_count_kept'} + $all_line_passed\n";
+ foreach my $anchor_and_index (@{$multitable->{'anchors'}},
@{$multitable->{'index_entries'}})
+ {
+ $anchor_and_index->{'line_nr'} +=
$multitable->{'line_count_kept'} + $all_line_passed;
+ }
+ if (! scalar(@{$info_state->{'multitable_stack'}}))
+ {
+ print STDERR "MULTITABLE close, lengths:
$multitable->{'offset_in_file_kept'} + $length\n";
+ foreach my $anchor (@{$multitable->{'anchors'}})
+ {
+ $anchor->{'info_offset'} +=
$multitable->{'offset_in_file_kept'} + $length;
+ }
+ }
+ else
+ {
+ push
@{$info_state->{'multitable_stack'}->[-1]->{'anchors'}},
@{$multitable->{'anchors'}};
+ push
@{$info_state->{'multitable_stack'}->[-1]->{'index_entries'}},
@{$multitable->{'index_entries'}};
+ }
+ $text_added .= $multitable->{'result'};
+ }
+ elsif ($content->{'command'} eq 'multitable_cell')
+ {
+ my $cell =
$info_state->{'multitable_stack'}->[-1]->{'cells'}->[-1];
+ $cell->{'result'} = $result;
+ $cell->{'length'} = $length;
+ $cell->{'line_passed'} = $all_line_passed;
+ }
+ elsif ($content->{'command'} eq 'direntry')
+ {
+ $direntry--;
+ #Â this has to be done here, otherwise, at the end, $direntry
+ #Â would be 0
+ $info_default_dir_specification .= $text_added;
+ $text_added = '';
+ }
+ elsif ($content->{'command'} eq 'multitable_row')
+ {
+ my $multitable = $info_state->{'multitable_stack'}->[-1];
+ my $row_length = 0;
+ my $row = '';
+ my $max_lines = 0;
+ my $cell_beginning = 0;
+ my @anchor_lines_array;
+ my $cell_idx = 0;
+ my @anchors;
+ my @indices;
+ foreach my $cell (@{$multitable->{'cells'}})
+ {
+ $cell->{'beginning'} = $cell_beginning;
+ $cell_beginning += $cell->{'cell_width'}+1;
+ @{$cell->{'lines'}} = split /^/, $cell->{'result'};
+ $max_lines = scalar(@{$cell->{'lines'}}) if
(scalar(@{$cell->{'lines'}}) > $max_lines);
+ foreach my $anchor (@{$cell->{'anchors'}})
+ {
+ push @{$anchor_lines_array[$anchor->{'line_nr'}]},
$anchor;
+ $anchor->{'cell_idx'} = $cell_idx;
+ push @anchors, $anchor;
+ }
+ push @indices, @{$cell->{'index_entries'}};
+ $cell_idx++;
+ }
+ my $previous_last_cell = scalar(@{$multitable->{'cells'}});
+ print STDERR "ROW cell_beginning $cell_beginning, max_lines
$max_lines, previous_last_cell $previous_last_cell\n";
+ for (my $line_idx = 0; $line_idx < $max_lines; $line_idx++)
+ {
+ my $length = 0;
+ my $line = '';
+ #Â determine the last cell in the line, to fill spaces in
+ # cells preceding that cell on the line
+ my $last_cell = 0;
+ for (my $cell_idx = 0; $cell_idx < $previous_last_cell;
$cell_idx++)
+ {
+ $last_cell = $cell_idx+1 if
(defined($multitable->{'cells'}->[$cell_idx]->{'lines'}->[$line_idx]));
+ }
+ print STDERR " L(last_cell $last_cell): $line_idx\n";
+ for (my $cell_idx = 0; $cell_idx < $last_cell; $cell_idx++)
+ {
+ my $cell_text =
$multitable->{'cells'}->[$cell_idx]->{'lines'}->[$line_idx];
+ print STDERR " C($cell_idx) ";
+ if (defined($cell_text))
+ {
+ chomp($cell_text);
+ print STDERR "$cell_text";
+ $line .= $cell_text;
+ $length += length($cell_text);
+ }
+ if ($cell_idx+1 < $last_cell)
+ {
+ if ($length <
$multitable->{'cells'}->[$cell_idx+1]->{'beginning'})
+ {
+ my $spaces = ' ' x
($multitable->{'cells'}->[$cell_idx+1]->{'beginning'} - $length);
+ $length += length($spaces);
+ $line .= $spaces;
+ print STDERR " Csp($length) `$spaces'";
+ }
+ }
+ }
+ if (defined($anchor_lines_array[$line_idx]))
+ {
+ foreach my $anchor (@{$anchor_lines_array[$line_idx]})
+ {
+ my $anchor_position = $anchor->{'line_char_counter'}
+ $multitable->{'cells'}->[$anchor->{'cell_idx'}]->{'beginning'};
+ if ($anchor_position > $length)
+ {
+ my $spaces = ' ' x ($anchor_position - $length);
+ $line .= $spaces;
+ $length += length($spaces);
+ }
+ $anchor->{'info_offset'} = $anchor_position +
$row_length + $multitable->{'length'};
+ print STDERR "ROW anchor close:
anchor[$anchor->{'cell_idx'}]($multitable->{'cells'}->[$anchor->{'cell_idx'}]->{'beginning'}+$anchor->{'line_char_counter'})
$anchor_position $anchor->{'info_offset'}\n";
+ $anchor->{'line_char_counter'} = $anchor_position;
+ }
+ }
+ $line .= "\n";
+ $row_length += length($line);
+ print STDERR " ($length,".length($line).") $line";
+ $row .= $line;
+ $previous_last_cell = $last_cell;
+ }
+ foreach my $anchor_and_index (@anchors, @indices)
+ {
+ $anchor_and_index->{'line_nr'} +=
$multitable->{'line_count'};
+ print STDERR "ROW close: new line count:
$anchor_and_index->{'line_nr'} + \n";
+ }
+ if ($content->{'item_command'} eq 'headitem')
+ {
+ # at this point cell_beginning is at the beginning of
+ #Â the cell following the end of the table -> full width
+ my $line = '-' x $cell_beginning . "\n";
+ $row .= $line;
+ $row_length += length($line);
+ }
+ print STDERR "ROW_LENGTH $row_length\n";
+ $multitable->{'result'} .= $row;
+ $multitable->{'length'} += $row_length;
+ $multitable->{'line_count'} += $max_lines;
+ $multitable->{'cells'} = [];
+ push @{$multitable->{'anchors'}}, @anchors;
+ push @{$multitable->{'index_entries'}}, @indices;
+ }
+ }
+ else
+ {
+ if ($content->{'command'})
+ {
+ my $pending_added_length = 0;
+ if ($content->{'command'} eq 'anchor' or $content->{'command'}
eq 'image' or $content->{'command'} eq 'index_command' or $content->{'command'}
eq 'sp')
+ {
+ my $pending;
+ ($line_char_counter, $pending_spaces, $pending_word,
$pending) = info_default_store_pending($line_char_counter, $pending_spaces,
$pending_word, $indent_length);
+ #Â here spaces out of any environment are ignored.
+ if ($in_para or $preformatted or $pending =~ /\S/)
+ { #Â this has to be done before the anchor related code
+ #Â to have the right count.
+ # FIXME this is wrong if an end of line was passed.
+ # in that case line_char_counter has been increased and
+ # $pending ends with an end of line
+ $pending_added_length += length($pending);
+ $text_added .= $pending;
+ }
+ }
+ if ($content->{'command'} eq 'anchor' or ($content->{'command'}
eq 'float' and $content->{'anchor_reference'}))
+ {
+print STDERR "anchor: offset_in_file $info_state->{'offset_in_file'},
line_count $info_state->{'line_count'}, line_char_counter $line_char_counter
pending_added_length $pending_added_length\n";
+ $content->{'anchor_reference'}->{'info_offset'} = $length +
$info_state->{'offset_in_file'} + $pending_added_length;
+ $content->{'anchor_reference'}->{'line_nr'} =
$all_line_passed + $info_state->{'line_count'};
+ $content->{'anchor_reference'}->{'line_char_counter'} =
$line_char_counter + $pending_added_length;
+ if (@{$info_state->{'multitable_stack'}})
+ {
+ push
@{$info_state->{'multitable_stack'}->[-1]->{'cells'}->[-1]->{'anchors'}},
$content->{'anchor_reference'};
+ }
+ push @{$info_state->{'pending_tags'}},
$content->{'anchor_reference'};
+ push @{$info_state->{'align_stack'}->[-1]->{'anchors'}},
$content->{'anchor_reference'} if
($info_state->{'align_stack'}->[-1]->{'command'} eq 'center' or
$info_state->{'align_stack'}->[-1]->{'command'} eq 'flushright');
+ }
+ elsif ($content->{'command'} eq 'index_label')
+ {
+ my $index_line_nr = $all_line_passed +
$info_state->{'line_count'};
+ my $index_name = $content->{'index_name'};
+ $info_default_index_line_string_length{$index_name} =
length($index_line_nr)
+ if
(!defined($info_default_index_line_string_length{$index_name}) or
$info_default_index_line_string_length{$index_name} < length($index_line_nr));
+print STDERR "RRRRRRRRRRRRR $content->{'index_entry_reference'}->{'texi'}
name: $index_name line: $index_line_nr max:
$info_default_index_line_string_length{$index_name}\n";
+ my $index_ref = { 'index_entry_reference' =>
$content->{'index_entry_reference'}, 'line_nr' => $index_line_nr, 'index_name'
=> $index_name };
+print STDERR "INDEX($index_name) line $index_line_nr\n";
+
$info_default_index_entries{$content->{'index_entry_reference'}} = $index_ref;
+ if (@{$info_state->{'multitable_stack'}})
+ {
+ push
@{$info_state->{'multitable_stack'}->[-1]->{'cells'}->[-1]->{'index_entries'}},
$index_ref;
+ }
+ push @{$info_state->{'pending_index_entries'}}, $index_ref;
+ }
+ elsif ($content->{'command'} eq '*' and !$preformatted)
+ {
+ if (defined($pending_word))
+ {
+ $text_added .= $pending_spaces . $pending_word;
+ $pending_word = undef;
+ }
+ #Â spaces preceding @* are skipped
+ $pending_spaces = '';
+ $text_added .= $content->{'text'};
+ #Â just like following spaces
+ info_default_skip_spaces($current, $index, $close);
+ goto new_text;
+ }
+ elsif ($content->{'command'} eq 'paragraph' and
$info_state->{'align_stack'}->[-1]->{'command'} eq 'normal')
+ {
+ #Â empty paragraph
+ goto new_text if (!$content->{'content'});
+ my $paragraphindent = get_conf('paragraphindent');
+ $paragraphindent = 0 if ($paragraphindent eq 'none');
+ if ($paragraphindent ne 'asis')
+ {
+ info_default_skip_spaces($current, $index, $close);
+ }
+ if ($paragraphindent ne 'asis' and $paragraphindent and
$line_char_counter == 0 and !($indent_level) and
!scalar(@{$info_state->{'multitable_stack'}}) and ($info_state->{'indent_para'}
or (!defined($info_state->{'indent_para'}) and
($content->{'paragraph_in_element_nr'} or (get_conf('firstparagraphindent') eq
'insert')))))
+ {
+ $text_added .= ' ' x $paragraphindent;
+ }
+ $in_para = 1;
+ }
+ elsif ($content->{'command'} eq 'preformatted')
+ {
+ $preformatted++ if ($content->{'content'});
+ }
+ elsif ($content->{'command'} eq 'exdent')
+ {
+ # if an end of line is added, in_exdent is set to 2 and
+ #Â set to one when processing the end of line that was just
+ #Â added, and set to 0 at the end of the line.
+ #Â if there is no end of line added, it is only set to 1.
+ if ($line_char_counter != 0)
+ {
+ $text_added .= "\n";
+ $in_exdent = 2;
+ }
+ else
+ {
+ $in_exdent = 1;
+ }
+ #goto new_text;
+ }
+ elsif ($content->{'command'} eq 'indent')
+ {
+ $info_state->{'indent_para'} = 1;
+ }
+ elsif ($content->{'command'} eq 'noindent')
+ {
+ $info_state->{'indent_para'} = 0;
+ }
+ elsif ($content->{'command'} eq 'image' or $content->{'command'}
eq 'sp')
+ {
+ $text_added .= $content->{'text'};
+ goto new_text;
+ }
+ elsif ($content->{'definition_line'})
+ {
+
+ my $dummy_line_passed;
+print STDERR "BUG: defined pending_word before DEFINITION_LINE\n" if
defined($pending_word);
+print STDERR
"DEFINITION_LINE($line_char_counter,$pending_spaces,$indent_length,$in_para,$max_column):
$content->{'text'}";
+ ($line_char_counter, $pending_spaces, $pending_word,
$dummy_line_passed, $text_added) =
info_default_process_text($content->{'text'}, $line_char_counter,
$pending_spaces, $pending_word, $indent_length, 1, $max_column,
$indent_length+2*$info_default_indent_length);
+ $text_added .= $pending_spaces;
+ $pending_spaces = '';
+ print STDERR
"DEFINITION_LINE($line_char_counter,$pending_spaces) -> $text_added";
+print STDERR "BUG: defined pending_word after DEFINITION_LINE\n" if
defined($pending_word);
+ $indentation_done = 1;
+
+ goto new_text;
+ }
+ elsif (($content->{'command'} eq 'item' or $content->{'command'}
eq 'itemx') and exists $format_map{$content->{'format_name'}})
+ {
+ $item_pending = $content->{'format_name'};
+ #if (!$info_state->{'blank_line'} and $content->{'command'}
eq 'item')
+ my $first_item = 0;
+
+ if ($content->{'command'} eq 'item')
+ {
+ if (!defined($content->{'parent'}->{'item_nr'}))
+ {
+ $content->{'parent'}->{'item_nr'} = 1;
+ $first_item = 1;
+ }
+ else
+ {
+ $content->{'parent'}->{'item_nr'}++;
+ }
+ }
+
+ if ($item_pending =~ /table$/)
+ {
+ $table_item_line = 1;
+ $in_table_item = 0;
+print STDERR "DDDDDDDDDDDDDDDD $content->{'command'} $first_item or
$indent_level $content->{'parent'}->{'command'}\n";
+ }
+ if (!$info_state->{'blank_line'} and ($content->{'command'}
ne 'itemx') and (!$first_item or $indent_level != 1))
+ {
+ $text_added = "\n" . $text_added;
+ $item_line_added = 1;
+ }
+ # one less indentation level and no line break
+ #Â adding item_line_added allows the table_item_line to
+ #Â still be active after the additional blank line
+ $table_item_line = 1+$item_line_added if ($item_pending =~
/table$/);
+ }
+ elsif ($content->{'command'} eq 'menu' or $content->{'command'}
eq 'listoffloats' or $content->{'heading_command'})
+ {
+ $text_added .= "\n" unless ($info_state->{'blank_line'});
+ }
+ elsif ($content->{'command'} eq 'direntry')
+ {
+ if ($content->{'content'})
+ {
+ $direntry++;
+ }
+ }
+ elsif ($paragraph_style{$content->{'command'}})
+ {
+ push @{$info_state->{'align_stack'}}, {'command' =>
$content->{'command'}};
+ }
+ elsif ($content->{'command'} eq 'verbatim' or
$content->{'command'} eq 'verbatiminclude')
+ {
+ #Â $preformatteed cannot be used here since preformatted
+ #Â is closed before a verbatim
+ if (!$preformatted_format and $indent_level != 0)
+ {
+ if (!$info_state->{'blank_line'} and
$info_state->{'only_spaces'})
+ {
+ $text_added .= "\n";
+ }
+ my $verb_text = $content->{'text'};
+ my ($line_passed, $end_of_line, $last_line,
$text_indented, $blank_line) = info_default_count_lines($verb_text);
+ $content->{'text'} .= "\n" unless ($blank_line or
($last_line =~ /^\s*$/));
+ }
+ }
+ elsif ($content->{'command'} eq 'multitable')
+ {
+ my $multitable = {
+ 'offset_in_file_kept' => $info_state->{'offset_in_file'},
+ 'line_count_kept' => $info_state->{'line_count'},
+ 'columns_size' => [ @{$content->{'columns_size'}}
],
+ 'result' => '',
+ 'length' => 0,
+ 'line_count' => 0,
+ 'result_kept' => $result,
+ 'length_kept' => $length,
+ 'all_line_passed_kept' => $all_line_passed,
+ 'line_char_counter_kept' => $line_char_counter,
+ 'max_column_kept' => $max_column,
+ };
+ push @{$info_state->{'multitable_stack'}}, $multitable;
+ $info_state->{'offset_in_file'} = 0;
+ $info_state->{'line_count'} = 0;
+ }
+ elsif ($content->{'command'} eq 'multitable_row')
+ {
+ $info_state->{'multitable_stack'}->[-1]->{'cell_index'} = -1;
+ }
+ elsif ($content->{'command'} eq 'multitable_cell')
+ {
+ my $multitable = $info_state->{'multitable_stack'}->[-1];
+ $multitable->{'cell_index'}++;
+ my $cell_width =
$content->{'parent'}->{'parent'}->{'columns_size'}->[$multitable->{'cell_index'}];
+ #$max_column = $cell_width-1;
+ $max_column = $cell_width -2;
+ my $cell = {'cell_width' => $cell_width, 'index_entries' =>
[], 'anchors' => []};
+ push @{$multitable->{'cells'}}, $cell;
+ $result = '';
+ $length = 0;
+ $all_line_passed = 0;
+ $line_char_counter = 0;
+ if (!$content->{'content'})
+ {# empty cell
+ $cell->{'result'} = $result;
+ $cell->{'length'} = $length;
+ $cell->{'line_passed'} = $all_line_passed;
+ }
+ #info_default_skip_spaces($current, $index, $close);
+ }
+ if ($info_default_indented_commands{$content->{'command'}})
+ {
+ if ($content->{'command'} =~ /^deff_item/)
+ {
+ info_default_skip_spaces($current, $index, $close);
+ }
+ elsif (!$info_state->{'blank_line'} and
$info_state->{'only_spaces'} and ($indent_level != 0) and !$preformatted)
+ {
+ $text_added .= "\n";
+ }
+ #Â there is no close if !$content->{'content'}
+ $indent_level++ if ($content->{'content'});
+ }
+ elsif ($complex_format_map->{$content->{'command'}} or
$content->{'command'} eq 'cartouche')
+ {
+ if (!$info_state->{'blank_line'} and
$info_state->{'only_spaces'} and ($indent_level != 0) and !$preformatted)
+ {
+ $text_added .= "\n";
+ }
+ }
+ if ($complex_format_map->{$content->{'command'}} and
$content->{'content'})
+ {
+ $preformatted_format++;
+ }
+ }
+
+ if (defined($content->{'text'}))
+ {
+ if ($in_para and !$in_exdent)
+ {
+print STDERR "IN_PARA text\n";
+ my $new_text = $content->{'text'};
+ if ((!defined($content->{'command'}) or
$content->{'command'} ne ':') and $new_text =~
/([$info_default_end_sentence_character])([$info_default_after_punctuation_characters]*)(\s*)$/)
+ {
+ #Â the info_default_after_punctuation_characters should
+ #Â always be in the same text element.
+ if (chomp($new_text))
+ {
+ $new_text =~ s/(\s*)$/ /;
+ }
+ else
+ {
+ # spaces may be in following commands
+ my ($current_next, $index_next, $close_next,
$text_next, $command_next) = info_default_next ($current, $index, $close);
+ while (1)
+ {
+ last if (!defined($current_next) or
(defined($command_next) and $command_next eq '*'));
+ if ($text_next =~ /\S/)
+ {
+ last;
+ }
+ else
+ {
+ if (chomp($text_next))
+ {
+ info_default_skip_spaces($current,
$index, $close);
+ $new_text =~ s/(\s*)$/ /;
+ last;
+ }
+ }
+ ($current_next, $index_next, $close_next,
$text_next, $command_next) = info_default_next ($current_next, $index_next,
$close_next);
+ }
+ }
+ print STDERR "KKKKKKKKKKKK `$1' `$2' `$3'";
+ }
+ elsif (chomp($new_text))
+ {
+ $new_text =~ s/(\s*)$/ /;
+ # if ($new_text =~
/[$info_default_end_sentence_character] $/)
+ # {
+ # $new_text .= ' ';
+ # }
+ }
+ $text_added .= $new_text;
+ } # ignore spaces outside of paragraphs and preformatted
+ elsif ($preformatted or
$info_state->{'align_stack'}->[-1]->{'command'} ne 'normal')
+ {
+print STDERR "IN_PREFORMATTED or ALIGN text\n";
+ $text_added .= $content->{'text'};
+ }
+ else
+ {
+ my $chomped_text = $content->{'text'};
+ if ($chomped_text !~ /\S/ and chomp($chomped_text) and
!$item_pending)
+ {
+ if ($in_table_item and $info_state->{'only_spaces'})
+ {
+ #Â in a blank_line
+print STDERR "IN_ITEM ignored: `$content->{'text'}'\n";
+ }
+ elsif (!$info_state->{'blank_line'} or
!$info_state->{'only_spaces'})
+ {
+print STDERR "IN_ADDING_BLANK_LINE because no line before or text before\n";
+ $text_added .= "\n";
+ }
+ else
+ {
+print STDERR "IN_NOT_ADDING_BLANK_LINE\n";
+ }
+ }
+ else
+ { #Â exdent, item not in paragraph nor in preformatted
+print STDERR "NOWHERE and not end of line (or item_pending)
`$content->{'text'}'\n";
+ $text_added .= $content->{'text'};
+ }
+ }
+# unless (!defined($line_char_counter) and !$preformatted and
$content->{'text'} =~ /^\s*$/);
+ }
+ else
+ {
+ if (defined($content->{'begin'}))
+ {
+ $text_added .= $content->{'begin'};
+ }
+ #Â command that won't be closed, so the end has to be added
+ #Â here. It should mostly happen for empty style @-commands.
+ if (defined($content->{'end'}) and
!defined($content->{'content'}))
+ {
+ $text_added .= $content->{'end'};
+ }
+ }
+ }
+ if (!$preformatted and !$in_exdent and
$info_state->{'align_stack'}->[-1]->{'command'} eq 'normal' and $in_para)
+ #if (!$preformatted and !$in_exdent)
+ {
+ #Â the line_passed returned here are not used, since they are
computed
+ #Â below.
+ $indentation_done = 1;
+ my $dummy_line_passed;
+ ($line_char_counter, $pending_spaces, $pending_word,
$dummy_line_passed, $text_added) = info_default_process_text($text_added,
$line_char_counter, $pending_spaces, $pending_word, $indent_length, $in_para,
$max_column, $indent_length_next_line) if ($text_added ne '');
+ }
+ elsif ($info_state->{'align_stack'}->[-1]->{'command'} ne 'center' and
$info_state->{'align_stack'}->[-1]->{'command'} ne 'flushright')
+ {
+
+ my $chomped_text = $text_added;
+ #if (chomp($chomped_text))
+ #{
+ # $in_exdent = 0;
+ #}
+ chomp($chomped_text);
+print STDERR "NOT IN PARA text_added `$text_added' line_char_counter
$line_char_counter\n";
+ if ($chomped_text ne '' and $line_char_counter < $indent_length)
+ {
+print STDERR " indent_length $indent_length\n";
+ $text_added = ' ' x ($indent_length -
$line_char_counter).$text_added;
+ }
+ $line_char_counter += length($text_added);
+ }
+ else
+ {
+ $line_char_counter += length($text_added);
+ }
+ new_text:
+print STDERR "ADDING `$text_added'\n" if ($text_added ne '');
+ if ($text_added ne '')
+ {
+ if ($item_pending and !$item_line_added)
+ {
+ info_default_skip_spaces($current, $index, $close);
+ $item_pending = undef;
+ }
+ }
+ #Â from here, the next cmmand is available
+ ($current, $index, $close) = info_default_iterator_next($current,
$index, $close);
+
+ if ($text_added =~ /\S/)
+ {
+ $in_table_item = 0 if ($in_table_item);
+ $info_state->{'blank_line'} = 0;
+ }
+ my ($line_passed, $end_of_line, $last_line, $text_indented, $blank_line)
= info_default_count_lines($text_added, $indent_length, ($indentation_done
+ or $info_state->{'align_stack'}->[-1]->{'command'} eq 'center'
+ or $info_state->{'align_stack'}->[-1]->{'command'} eq 'flushright'));
+ $info_state->{'blank_line'} = 1 if ($blank_line);
+ #Â only_space is set in all the conditionals
+ if ($end_of_line)
+ {
+ $line_char_counter = 0;
+ $in_exdent-- if ($in_exdent);
+ if ($table_item_line)
+ {
+ $table_item_line--;
+ $in_table_item = 1;
+ }
+ $info_state->{'blank_line'} = 1 if ($info_state->{'only_spaces'} and
($last_line !~ /\S/));
+ $info_state->{'only_spaces'} = 1;
+ }
+ else
+ {
+ if ($line_passed)
+ {# in that case we added more than one line, the $line_char_counter
+ #Â is reset to the last line length.
+ $line_char_counter = length($last_line);
+ $in_exdent = 0;
+ if ($last_line !~ /\S/)
+ {
+ $info_state->{'only_spaces'} = 1;
+ }
+ else
+ {
+ $info_state->{'only_spaces'} = 0;
+ }
+ }
+ else
+ {
+ $info_state->{'only_spaces'} = 0 if ($last_line =~ /\S/);
+ }
+ }
+ if ($info_state->{'align_stack'}->[-1]->{'command'} eq 'center'
+ or $info_state->{'align_stack'}->[-1]->{'command'} eq 'flushright')
+ {
+ if (defined($current_line))
+ {
+ $text_added = $current_line . $text_added;
+ }
+ $text_indented = '';
+ $current_line = undef;
+ my $length_prepended = undef;
+ foreach my $line (split /^/, $text_added)
+ {
+ my $chomped_line = $line;
+ if (chomp($chomped_line))
+ {
+ $line =~ s/^\s*//;
+ $line =~ s/\s*$//;
+
+ if (length($line) eq 0)
+ {
+ $length_prepended = 0;
+ $text_indented .= "\n";
+ }
+ else
+ {
+ if (length($line) > $max_column)
+ {
+ $length_prepended = 0;
+ }
+ elsif ($info_state->{'align_stack'}->[-1]->{'command'} eq
'center')
+ {
+ $length_prepended = (($max_column -1 - length($line))
/2);
+ }
+ else
+ {
+ $length_prepended = ($max_column -1 - length($line));
+ }
+ $text_indented .= ' ' x$length_prepended . $line ."\n";
+ }
+ }
+ else
+ {
+ $current_line = $line;
+ }
+ }
+ if (defined ($length_prepended) and
defined($info_state->{'align_stack'}->[-1]->{'anchors'}))
+ {
+ while (@{$info_state->{'align_stack'}->[-1]->{'anchors'}})
+ {
+ my $anchor = shift
@{$info_state->{'align_stack'}->[-1]->{'anchors'}};
+ $anchor->{'info_offset'} += $length_prepended;
+ }
+ }
+ }
+
+ if ($direntry)
+ {
+ $info_default_dir_specification .= $text_indented;
+ }
+ else
+ {
+ $result .= $text_indented;
+ $length += length($text_indented);
+ $all_line_passed += $line_passed;
+ }
+ }
+ return ($length, $result, $all_line_passed);
+}
+
+sub info_default_open_command($$;$)
+{
+ my $state = shift;
+ my $command = shift;
+ my $additional_entries = shift;
+
+ my $index = 0;
+
+ my $info_state = info_default_get_state($state);
+ #Â index in the parent content list
+ $index = scalar(@{$info_state->{'current'}->{'content'}})
+ if (defined($info_state->{'current'}->{'content'}));
+ my $new_command = {'command' => $command, 'parent' =>
$info_state->{'current'}, 'index_in_parent' => $index };
+ if (defined($additional_entries))
+ {
+ foreach my $key (keys(%$additional_entries))
+ {
+ $new_command->{$key} = $additional_entries->{$key};
+ }
+ }
+
+ push @{$info_state->{'current'}->{'content'}}, $new_command;
+ $info_state->{'current'} = $new_command;
+ print STDERR "Opened $command ".
+ "\n";
+}
+
+sub info_default_close_command($$;$$$)
+{
+ my $state = shift;
+ my $command = shift;
+ my $begin = shift;
+ my $end = shift;
+ my $command_entries = shift;
+
+ $state = $Texi2HTML::THISDOC{'state'} if (!defined($state));
+ my $info_state = info_default_get_state($state);
+ print STDERR "Closing $command ".
+ "\n";
+ if (!defined($info_state->{'current'}))
+ {
+ print STDERR "info_state->{'current'} not defined\n";
+ }
+ elsif (!defined($info_state->{'current'}->{'command'}))
+ {
+ print STDERR "info_state->{'current'}->{'command'} not defined\n";
+ }
+ elsif ($command ne $info_state->{'current'}->{'command'})
+ {
+ print STDERR "Was waiting for $info_state->{'current'}->{'command'}\n";
+ }
+ #return if $no_close;
+ $command_entries->{'begin'} = $begin;
+ $command_entries->{'end'} = $end;
+ foreach my $key (keys(%$command_entries))
+ {
+ $info_state->{'current'}->{$key} = $command_entries->{$key}
+ if (defined($command_entries->{$key}));
+ }
+
+ $info_state->{'current'} = $info_state->{'current'}->{'parent'};
+
+ return info_default_output($info_state)
+ if (!defined($info_state->{'current'}->{'command'}));
+ return '';
+}
+
+sub info_default_store_text($$;$$)
+{
+ my $state = shift;
+ my $text = shift;
+ my $command = shift;
+ my $text_entries = shift;
+
+ $state = $Texi2HTML::THISDOC{'state'} if (!defined($state));
+ my $info_state = info_default_get_state($state);
+ return '' if ((!defined($text) or $text eq '') and !defined($command));
+
+ my $command_text = '';
+ $command_text = "\[$command\]" if (defined($command));
+ $command_text .= $text if (defined($text));
+ print STDERR "Storing text ${command_text}\n";
+
+ $text_entries->{'text'} = $text if (defined($text));
+ $text_entries->{'command'} = $command if (defined($command));
+ $text_entries->{'parent'} = $info_state->{'current'};
+ push @{$info_state->{'current'}->{'content'}}, $text_entries;
+ return info_default_output($info_state)
+ if (!defined($info_state->{'current'}->{'command'}));
+ return '';
+}
+
+sub info_default_begin_format_texi($$$)
+{
+ my $command = shift;
+ my $line = shift;
+ my $state = shift;
+
+ my $info_state = info_default_get_state ($state);
+ my ($parent_format, $in_format);
+ ($parent_format, $in_format) =
info_default_parent_format($info_state->{'current'});
+ $info_state->{'paragraph_in_element_nr'}++ if (!$in_format);
+
+ $parent_format->{'paragraph_in_element_nr'} = 0 if
(!defined($parent_format->{'paragraph_in_element_nr'}));
+ $parent_format->{'paragraph_in_element_nr'}++;
+
+ info_default_open_command($state,$command) unless ($def_map{$command} and
$command =~ /x$/);
+ return $line;
+}
+
+sub info_default_begin_style_texi($$$$)
+{
+ my $command = shift;
+ my $state = shift;
+ my $stack = shift;
+ my $real_style_command = shift;
+ info_default_open_command($state,$command)
+ unless ($info_default_accent_commands{$command} or exists
$things_map{$command});
+# if ($real_style_command);
+}
+
+sub info_default_begin_paragraph_texi($$$)
+{
+ my $command = shift;
+ my $paragraph_macros = shift;
+ my $paragraph_command = shift;
+ #print STDERR "begin_paragraph $command\n";
+ my $state = shift;
+ my $stack = shift;
+ #my $info_state = info_default_get_state($state);
+ info_default_open_command($state,$command);
+ foreach my $style_command (@$paragraph_macros)
+ {
+ print STDERR "para stack: $style_command->{'style'}\n";
+ info_default_open_command($state,$style_command->{'style'});
+ #$info_state->{'current'}->{'no_open'} = 1;
+ }
+}
+
+sub info_default_simple_command($$$$)
+{
+ my $command = shift;
+ my $in_preformatted = shift;
+ my $line_nr = shift;
+ my $state = shift;
+
+ my $result = $simple_map{$command};
+ #Â discards '-' '|' '/' and ':'. If ':' is associated with a punctuation
+ #Â character it is added to the tree in info_default_colon_command
+ return info_default_store_text($state,$result,$command) if ($result ne '');
+ return '';
+ #return '' if info_default_store_text($state,$result,$command);
+ #return $result;
+}
+
+sub info_default_colon_command($)
+{
+ my $punctuation_character = shift;
+ if (defined($colon_command_punctuation_characters{$punctuation_character})
+ and $punctuation_character =~ /^[$punctuation_characters]$/)
+ {
+ return
info_default_store_text(undef,$colon_command_punctuation_characters{$punctuation_character},
':');
+ }
+ else
+ {
+ return info_default_store_text(undef,$punctuation_character);;
+ }
+}
+
+sub info_default_thing_command($$$$$)
+{
+ my $command = shift;
+ my $text = shift;
+ my $in_preformatted = shift;
+ my $line_nr = shift;
+ my $state = shift;
+
+ my $result = $things_map{$command};
+ #return info_default_close_command($state, $command, $result, $text, '');
+ return info_default_store_text($state, $result, $command);
+# return $result . $text;
+}
+
+
+sub info_default_style($$$$$$$$$)
+{
+ my $style = shift;
+ my $command = shift;
+ my $text = shift;
+ my $args = shift;
+ my $no_close = shift;
+ my $no_open = shift;
+ my $line_nr = shift;
+ my $state = shift;
+ my $command_stack = shift;
+
+ my $begin = '';
+ my $end = '';
+
+ #Â note that the $text is always discarded for closed commands
+
+ #Â the formatting is done right here, without information on the current
+ #Â state, and the result is entered as text below.
+ if ($info_default_leaf_command{$command})
+ {
+ my $style_index = 0;
+ my @formatted_args = ();
+ foreach my $arg (@$args)
+ {
+ my $arg_style = $style->{'orig_args'}->[$style_index];
+ if ($arg_style eq 'normal')
+ {
+ push @formatted_args, main::substitute_line($arg,
"address@hidden");
+ }
+ elsif ($arg_style eq 'code')
+ {
+ push @formatted_args, main::substitute_line($arg,
"address@hidden", {'code_style' => 1});
+ }
+ else
+ {
+ print STDERR "Unknown arg style($style_index) $arg_style for
$command\n";
+ }
+ $style_index++;
+ }
+ $args = address@hidden;
+ }
+ if (defined($style->{'function'}))
+ {
+ $text = &{$style->{'function'}}($command, $args, $command_stack, $state,
$line_nr);
+ }
+ if (defined($style->{'begin'}) and !$no_open)
+ {
+ $begin = $style->{'begin'};
+ }
+ if (defined($style->{'end'}) and !$no_close)
+ {
+ $end = $style->{'end'};
+ }
+ unless($special_style{$command} or ($command eq 'cmd_line') or
$info_default_accent_commands{$command} or ($command eq 'hyphenation') or
$info_default_leaf_command{$command})
+ {
+ return info_default_close_command($state, $command, $begin, $end);
+ }
+ #Â this is for *ref, images and footnotes text registering and putting
+ #Â in the tree.
+ #Â anchor is already in the tree, from anchor_label.
+ if (($special_style{$command} or $info_default_leaf_command{$command}) and
$command ne 'anchor')
+ {
+ return info_default_store_text ($state, $begin.$text.$end, $command);
+ }
+ #Â we go here for cmd_line, and also for accents, hyphenation and anchor
+ #Â (though the result for anchor is always an empty string).
+ return $begin.$text.$end;
+}
+
+sub info_default_header ()
+{
+ return $Texi2HTML::THISDOC{'info_header'} if
(defined($Texi2HTML::THISDOC{'info_header'}));
+ #my $result = "This is $setfilename, produced by
$Texi2HTML::THISDOC{program} from $Texi2HTML::THISDOC{'input_file_name'}.\n\n";
+ #Â the following is wrong, $Texi2HTML::THISDOC{'input_file_name'}
+ #Â should be used
+ #Â directly, but then tests are not reproducible in out of source builds
+ my $basename = $Texi2HTML::THISDOC{'input_file_name'};
+ $basename =~ s/^.*\/// if ($TEST);
+ $basename = $STDIN_DOCU_NAME if ($basename eq '-');
+ my $result = "This is $Texi2HTML::THISDOC{'filename'}->{'top'}, produced
by makeinfo version 4.13 from $basename. ";
+ my $dummy;
+ ($dummy, $dummy, $dummy, $dummy, $result) =
info_default_process_text($result, 0, '', undef, undef, 1,
get_conf('fillcolumn'));
+ $result .= "\n\n";
+ $result .= "$Texi2HTML::THISDOC{'copying_comment'}";
+ if ($info_default_dir_specification)
+ {
+ $result .= "$info_default_dir_specification\n";
+ }
+ $Texi2HTML::THISDOC{'info_header'} = $result;
+ return $result;
+}
+
+sub info_default_print_page_head($)
+{
+ my $fh = shift;
+ my $header = info_default_header();
+ print $fh "".$header;
+
+ my $state = $Texi2HTML::THISDOC{'state'};
+ my $info_state = info_default_get_state ($state);
+ $info_state->{'offset_in_file'} += length($header);
+ $info_state->{'blank_line'} = 1 if ($Texi2HTML::THISDOC{'copying_comment'}
eq '');
+}
+
+sub info_default_parent_format($)
+{
+ my $parent_format = shift;
+ my $in_format = 0;
+ while (1)
+ {
+ if (defined($parent_format->{'command'}) and
$info_default_format{$parent_format->{'command'}})
+ {
+ $in_format = 1;
+ last;
+ }
+ last if (!defined($parent_format->{'parent'}));
+ $parent_format = $parent_format->{'parent'};
+ }
+ return ($parent_format, $in_format);
+}
+
+sub info_default_paragraph($$$$$$$$$$$$)
+{
+ my $text = shift;
+ my $align = shift;
+ my $indent = shift;
+ my $paragraph_command = shift;
+ my $paragraph_command_formatted = shift;
+ my $paragraph_number = shift;
+ my $format = shift;
+ my $item_nr = shift;
+ my $enumerate_style = shift;
+ my $number = shift;
+ my $command_stack_at_end = shift;
+ my $command_stack_at_begin = shift;
+
+ my $top_stack = '';
+ $top_stack = $command_stack_at_begin->[-1] if (scalar
(@$command_stack_at_begin));
+
+ my $state = $Texi2HTML::THISDOC{'state'};
+ my $info_state = info_default_get_state ($state);
+ my ($parent_format, $in_format);
+ ($parent_format, $in_format) =
info_default_parent_format($info_state->{'current'}->{'parent'});
+ $parent_format->{'paragraph_in_format_nr'} = 0 if
(!defined($parent_format->{'paragraph_in_format_nr'}));
+ $parent_format->{'paragraph_in_format_nr'}++;
+
+ $info_state->{'paragraph_in_element_nr'}++ if (!$in_format);
+ my $additional_args = {'top_stack' => $top_stack, 'parent_format' =>
$parent_format};
+ $additional_args->{'paragraph_in_element_nr'} =
($info_state->{'paragraph_in_element_nr'} - 1) if (!$in_format);
+
+ return info_default_close_command(undef, 'paragraph', undef, undef,
$additional_args);
+}
+
+# currently not used, but could be used if info_default_preformatted
+#Â return something that is not 'false', for example spaces, though we
+#Â want the preformatted to be ignored. Though it is not sure that if there
+#Â are spaces we want to ignore the preformatted.
+sub info_default_empty_preformatted($)
+{
+ my $text = shift;
+ my $result = info_default_preformatted($text, undef, undef, undef, undef,
+ undef, undef, undef, undef, undef, undef, undef);
+ return 0;
+}
+
+sub info_default_preformatted($$$$$$$$$$$$)
+{
+ my $text = shift;
+ my $pre_style = shift;
+ my $class = shift;
+ my $leading_command = shift;
+ my $leading_command_formatted = shift;
+ my $preformatted_number = shift;
+ my $format = shift;
+ my $item_nr = shift;
+ my $enumerate_style = shift;
+ my $number = shift;
+ my $command_stack_at_end = shift;
+ my $command_stack_at_begin = shift;
+
+ return info_default_close_command(undef, 'preformatted');
+}
+
+
+sub info_default_node_line($$)
+{
+ my $element = shift;
+ my $info_state = shift;
+ my $outfile = $Texi2HTML::THISDOC{'filename'}->{'top'};
+ $outfile = $STDOUT_DOCU_NAME if ($outfile eq '-');
+ my $result = "\x{1F}\nFile: $outfile, Node: $element->{'text'}";
+ if (defined($element->{'NodeNext'}))
+ {
+ $result .= ','.&$I(' Next: %{node_next}', {'node_next' =>
$element->{'NodeNext'}->{'text'}});
+ }
+ if (defined($element->{'NodePrev'}))
+ {
+ $result .= ','.&$I(' Prev: %{node_prev}', {'node_prev' =>
$element->{'NodePrev'}->{'text'}});
+ }
+ if (defined($element->{'NodeUp'}))
+ {
+ $result .= ','.&$I(' Up: %{node_up}', {'node_up' =>
$element->{'NodeUp'}->{'text'}});
+ }
+ $result .= "\n\n";
+ $info_state->{'line_count'} = 3;
+ $info_state->{'offset_in_file'} += length($result);
+ $info_state->{'blank_line'} = 1;
+ return $result;
+}
+
+sub info_default_element_heading($$$$$$$$$$$$)
+{
+ my $element = shift;
+ my $command = shift;
+ my $texi_line = shift;
+ my $line = shift;
+ my $in_preformatted = shift;
+ my $one_section = shift;
+ my $element_heading = shift;
+ my $first_in_page = shift;
+ my $is_top = shift;
+ my $previous_is_top = shift;
+ my $command_line = shift;
+ my $element_id = shift;
+ my $new_element = shift;
+
+ my $state = $Texi2HTML::THISDOC{'state'};
+ my $info_state = info_default_get_state ($state);
+
+ #Â FIXME use $element or $Texi2HTML::THIS_ELEMENT? Main program should
+ #Â ensure they are the same.
+ if ($new_element and ($element ne $new_element or !$element->{'node'}))
+ {
+ die "There is a new element, but element $element->{'texi'} is not a
node or not the new element\n";
+ }
+ return &$heading($element, $command, $texi_line, $line, $in_preformatted,
$one_section, $element_heading) unless ($new_element);
+
+print STDERR "HHHHHHHHHHHHHHH node($element->{'texi'}) $info_state->{'nr'}\n";
+ my $before = '';
+ $element->{'info_offset'} = $info_state->{'offset_in_file'};
+ push @{$info_state->{'pending_tags'}}, $element;
+
+ my $result = info_default_node_line($element, $info_state);
+
+ $info_default_footnote_index = 0;
+ $info_default_current_node = $element;
+
+ return $before.$result;
+}
+
+sub info_default_heading($$$$$;$$)
+{
+ my $element = shift;
+ my $command = shift;
+ my $texi_line = shift;
+ my $line = shift;
+ my $in_preformatted = shift;
+ my $one_section = shift;
+ my $element_heading = shift;
+
+ die "Heading called for a node\n" if ($element->{'node'});
+ my $state = $Texi2HTML::THISDOC{'state'};
+ my $info_state = info_default_get_state ($state);
+print STDERR "HHHHHHHHHHHHHHH section($element->{'texi'})
$info_state->{'nr'}\n";
+ $info_state->{'paragraph_in_element_nr'} = 0;
+ my $text = "$element->{'text'}";
+ #Â to do the same than makeinfo a trailing dot in section number is removed
+ $text =~ s/^(\w+)\. /$1 /;
+ #Â when @top is empty, use settitle
+ $text = $Texi2HTML::THISDOC{'settitle'} if (!length($text) and
$element->{'tag'} eq 'top' and defined ($Texi2HTML::THISDOC{'settitle'}) and
length($Texi2HTML::THISDOC{'settitle'}));
+ $text = "Annexe $text" if ($element->{'tag'} =~ /appendix/ and
$element->{'level'} <= 1);
+ my $result = $text . "\n" .
+ ($default_info_level_to_symbol{$element->{'level'}} x length($text)) .
"\n";
+
+ $result .= "\n";
+
+ return info_default_store_text($state, $result, $command,
{'heading_command' => 1});
+}
+
+sub info_default_normal_text($$$$$$;$)
+{
+ my @initial_args = @_;
+ my $text = shift;
+ my $in_raw_text = shift; # remove_texi
+ my $in_preformatted = shift;
+ my $in_code = shift;
+ my $in_simple = shift;
+ my $style_stack = shift;
+ my $state = shift;
+
+ #Â $Texi2HTML::THISDOC{'ENCODING_NAME'}) should be defined, but maybe
+ # not when parsing commands in first or second pass, and removeing texi
+ #Â like what is done for @setfilename.
+ if ($ENABLE_ENCODING and !$ENABLE_ENCODING_USE_ENTITY and
defined($Texi2HTML::THISDOC{'ENCODING_NAME'}) and
($Texi2HTML::THISDOC{'ENCODING_NAME'} eq 'utf-8'))
+ {
+ $text = &t2h_utf8_normal_text(@initial_args);
+ }
+ else
+ {
+#print STDERR "info_default_normal_text $text $in_preformatted $in_code \n";
+ $text = uc($text) if (in_cmd($style_stack, 'sc'));
+ $text = uc($text) if (in_cmd($style_stack, 'var'));
+# $text = &$protect_text($text) unless($in_raw_text);
+ if (! $in_code and !$in_preformatted)
+ {
+ $text =~ s/---/\x{1F}/g;
+ $text =~ s/--/-/g;
+ $text =~ s/\x{1F}/--/g;
+ $text =~ s/``/"/g;
+ $text =~ s/\'\'/"/g;
+ }
+ else
+ {
+ # to be like texinfo
+# my $special_code = 0;
+# $special_code = 1 if (in_cmd($style_stack, 'code') or
+# in_cmd($style_stack, 'example') or in_cmd($style_stack,
'verbatim'));
+# $text =~ s/'/\&rsquo\;/g unless ($special_code and
exists($main::value{'txicodequoteundirected'}));
+# $text =~ s/`/\&lsquo\;/g unless ($special_code and
exists($main::value{'txicodequotebacktick'}));
+ }
+ }
+ #Â accented characters are not handled as text, but when the last
+ #Â accent command on the stack is closed.
+ if ($style_stack and @$style_stack and
$info_default_accent_commands{$style_stack->[-1]})
+ {
+ return $text;
+ }
+ return info_default_store_text($state,$text);
+ #Â We never store in the stack text in raw text (remove_texi).
+# unless ($in_raw_text)
+# {
+# return '' if (info_default_store_text($state,$text));
+# }
+# return $text;
+}
+
+#Â this is not called in preformatted
+sub info_default_empty_line($$)
+{
+ my $text = shift;
+ my $state = shift;
+ #ignore the line if it just follows a deff
+ #return '' if ($state->{'deff_line'});
+ return info_default_store_text($state,$text);
+# return '';
+}
+
+#Â change interface?
+sub info_default_anchor_label($$$)
+{
+ my $id = shift;
+ my $anchor_text = shift;
+ my $anchor_reference = shift;
+ print STDERR "Storing anchor $anchor_reference->{'text'}\n";
+ return info_default_store_text(undef,undef,'anchor',{'anchor_reference' =>
$anchor_reference});
+}
+
+sub info_default_acronym_like($$$$$$)
+{
+ my $command = shift;
+ my $acronym_texi = shift;
+ my $acronym_text = shift;
+ my $with_explanation = shift;
+ my $explanation_lines = shift;
+ my $explanation_text = shift;
+ my $explanation_simply_formatted = shift;
+
+ if ($with_explanation)
+ {
+ return "$acronym_text ($explanation_text)";
+ }
+ else
+ {
+ return "$acronym_text";
+ }
+}
+
+
+sub info_default_print_page_foot($)
+{
+ my $fh = shift;
+ my $state = $Texi2HTML::THISDOC{'state'};
+ my $info_state = info_default_get_state ($state);
+ my $indirect = 0;
+ return unless (defined ($info_state->{'pending_tags'}));
+ $indirect = 1 if ($info_default_out_file_nr > 1);
+ if ($indirect)
+ {
+ close ($Texi2HTML::THISDOC{'FH'});
+ unless (rename
("$Texi2HTML::THISDOC{'destination_directory'}$Texi2HTML::THISDOC{'filename'}->{'top'}",
"$Texi2HTML::THISDOC{'destination_directory'}$Texi2HTML::THISDOC{'filename'}->{'top'}-1"))
+ {
+ warn "Rename
$Texi2HTML::THISDOC{'destination_directory'}$Texi2HTML::THISDOC{'filename'}->{'top'}
failed: $!\n";
+ }
+ unless (open (INDIRECT,
">$Texi2HTML::THISDOC{'destination_directory'}$Texi2HTML::THISDOC{'filename'}->{'top'}"))
+ {
+ warn "Open
$Texi2HTML::THISDOC{'destination_directory'}$Texi2HTML::THISDOC{'filename'}->{'top'}
failed: $!\n";
+ }
+ print INDIRECT "".info_default_header();
+ print INDIRECT "\x{1F}\nIndirect:";
+ foreach my $indirect (@info_default_pending_indirect)
+ {
+ print INDIRECT "\n$indirect->{'file'}: $indirect->{'offset'}";
+ }
+ $fh = \*INDIRECT;
+ }
+ #Â makeinfo seems to add systematically an additional \n, done just below
+ print $fh "\n\x{1F}\nTag Table:\n";
+
+ if ($indirect)
+ {
+ print $fh "(Indirect)\n";
+ }
+ foreach my $element (@{$info_state->{'pending_tags'}})
+ {
+ my $prefix;
+ $prefix = 'Node' if ($element->{'node'});
+ $prefix = 'Ref' if ($element->{'anchor'} or $element->{'float'});
+ print $fh "$prefix: $element->{'text'}\x{7F}$element->{'info_offset'}\n";
+ }
+ print $fh "\x{1F}\nEnd Tag Table\n";
+ if (defined($Texi2HTML::THISDOC{'DOCUMENT_ENCODING'}))
+ {
+ my $coding = $Texi2HTML::THISDOC{'DOCUMENT_ENCODING'};
+ if ($coding =~ /^iso-/i)
+ {
+ $coding = lc($coding);
+ }
+ print $fh "\n\x{1F}\nLocal Variables:\ncoding: $coding\nEnd:\n";
+ }
+}
+
+sub info_default_print_Top_footer($$$)
+{
+ my $fh = shift;
+ my $end_page = shift;
+ my $element = shift;
+ if ($end_page)
+ {
+ &$print_page_foot($fh);
+ }
+ info_default_end_section($fh, $end_page, $element);
+}
+
+sub info_default_footnote_texi($$$)
+{
+ my $text = shift;
+ my $state = shift;
+ my $style_stack = shift;
+
+ $info_default_footnote_index++;
+ return "($info_default_footnote_index) $text";
+}
+
+sub info_default_print_section
+{
+ my $fh = shift;
+ my $first_in_page = shift;
+ my $previous_is_top = shift;
+ my $element = shift;
+ my $nw = main::print_lines($fh);
+ my $state = $Texi2HTML::THISDOC{'state'};
+ my $info_state = info_default_get_state ($state);
+ if (!$info_state->{'blank_line'})
+ {
+ my $end = "\n";
+ $info_state->{'offset_in_file'} += length($end);
+ $info_state->{'line_count'}++;
+ print $fh "$end";
+ }
+ if (@info_default_pending_footnotes)
+ {
+ my $footnote_text;
+ my $footnote_element;
+ if (get_conf('footnotestyle') eq 'separate')
+ {
+ my $node_ref = $info_default_current_node;
+ $node_ref = {'text' => 'no node', 'file' => ''} if
(!defined($node_ref));
+ $footnote_element = { 'NodeUp' => $node_ref,
+ 'text' => $node_ref->{'text'} . "-Footnotes",
+ 'file' => $node_ref->{'file'},
+ 'info_offset' => $info_state->{'offset_in_file'},
+ 'node' => 1
+ };
+ push @{$info_state->{'pending_tags'}}, $footnote_element;
+ $footnote_text = info_default_node_line($footnote_element,
$info_state);
+ }
+ else
+ {
+ $footnote_text = " ---------- Footnotes ----------\n\n";
+ $info_state->{'offset_in_file'} += length($footnote_text);
+ $info_state->{'line_count'} += 2;
+print STDERR "MMMMMMMMMMMMMMMMMM $info_state->{'line_count'}\n";
+ }
+ while (@info_default_pending_footnotes)
+ {
+ #push @info_default_pending_footnotes, [$lines, $footnote_text,
${info_default_footnote_index}, $node_name, $footnote_info_state];
+ my $footnote = shift @info_default_pending_footnotes;
+ my $foot_nr = $footnote->{'footnote_index'};
+ my $node_name = $footnote->{'node_name'};
+ my $lines = $footnote->{'lines'};
+ push @{$info_state->{'pending_tags'}}, {'anchor' => 1, 'text' =>
"${node_name}-Footnote-${foot_nr}", 'info_offset' =>
$info_state->{'offset_in_file'} };
+ my $footnote_info_state = $footnote->{'footnote_info_state'};
+ my $footnote_result = shift @{$lines};
+ my $initial_length = length($footnote_result);
+
+ $footnote_result =~ s/^\s*//;
+ #$footnote_result = " ($foot_nr) " . $footnote_result;
+ $footnote_result = ' ' x get_conf('paragraphindent') .
$footnote_result;
+ foreach my
$footnote_pending_tags(@{$footnote_info_state->{'pending_tags'}})
+ {
+ $footnote_pending_tags->{'info_offset'} +=
$info_state->{'offset_in_file'} + length($footnote_result) - $initial_length;
+ push @{$info_state->{'pending_tags'}}, $footnote_pending_tags;
+ }
+ foreach my
$footnote_pending_index_entry(@{$footnote_info_state->{'pending_index_entries'}})
+ {
+print STDERR
"TTTTTTTTTTT($footnote_pending_index_entry->{'index_entry_reference'}->{'entry'})
$footnote_pending_index_entry->{'line_nr'} $info_state->{'line_count'}\n";
+ $footnote_pending_index_entry->{'line_nr'} +=
$info_state->{'line_count'};
+
$footnote_pending_index_entry->{'index_entry_reference'}->{'real_element'} =
$footnote_element if (get_conf('footnotestyle') eq 'separate');
+ }
+ my $line;
+ while (@$lines)
+ {
+ $line = shift @$lines;
+ $footnote_result .= $line;
+ }
+ my ($line_passed, $end_of_line, $last_line, $text_indented,
$blank_line) = info_default_count_lines($footnote_result);
+ if ($line_passed == 0)
+ {#Â certainly out of paragraph commands
+ $footnote_result =~ s/\s*$//;
+ $footnote_result .= "\n";
+ $line_passed = 1;
+ }
+ unless (($last_line !~ /\S/ and $end_of_line) or ($blank_line))
+ {
+ $footnote_result .= "\n";
+ $line_passed += 1;
+ }
+
+ $info_state->{'offset_in_file'} += length($footnote_result);
+ $info_state->{'line_count'} += $line_passed;
+ $footnote_text .= $footnote_result;
+ }
+ print $fh "$footnote_text";
+ }
+}
+
+sub info_default_end_section($$$)
+{
+ my $fh = shift;
+ my $end_foot_navigation = shift;
+ my $element = shift;
+ my $state = $Texi2HTML::THISDOC{'state'};
+ my $info_state = info_default_get_state ($state);
+
+ if (defined($Texi2HTML::THISDOC{'SPLIT_SIZE'}) and
+ $info_state->{'offset_in_file'} > ($info_default_out_file_nr) *
$Texi2HTML::THISDOC{'SPLIT_SIZE'})
+ {
+ if ($info_default_out_file_nr == 1)
+ {
+ push @info_default_pending_indirect,
{'file'=>"$Texi2HTML::THISDOC{'filename'}->{'top'}-$info_default_out_file_nr",
'offset' => $info_state->{'pending_tags'}->[0]->{'info_offset'} };
+ }
+ $info_default_out_file_nr++;
+ close($Texi2HTML::THISDOC{'FH'});
+ if (!$end_foot_navigation)
+ {
+
main::open_out_file("$Texi2HTML::THISDOC{'filename'}->{'top'}-$info_default_out_file_nr");
+ print STDERR "X-$info_default_out_file_nr:
$info_state->{'offset_in_file'}\n";
+ &$print_page_head($Texi2HTML::THISDOC{'FH'});
+ push @info_default_pending_indirect,
{'file'=>"$Texi2HTML::THISDOC{'filename'}->{'top'}-$info_default_out_file_nr",
'offset' => $info_state->{'offset_in_file'}};
+ }
+ }
+}
+
+sub info_default_one_section($$)
+{
+ my $fh = shift;
+ my $element = shift;
+ &$print_section($fh, 1, 0, $element);
+ &$print_page_foot($fh);
+}
+
+sub info_default_begin_special_region($$$)
+{
+ my $region = shift;
+ my $state = shift;
+ my $lines = shift;
+ my $info_state = info_default_get_state ($state);
+ #Â reset paragraph_in_element_nr if out ofdocument formatting
+ if ($state->{'outside_document'})
+ {
+ $info_state->{'paragraph_in_element_nr'} = 0;
+ }
+}
+
+sub info_default_end_special_region($$$)
+{
+ my $region = shift;
+ my $state = shift;
+ my $text = shift;
+ my $info_state = info_default_get_state ($state);
+ my $end = '';
+ if (!$info_state->{'blank_line'})
+ {
+ $end = "\n";
+ $info_state->{'offset_in_file'} += length($end);
+ }
+ return $text.$end;
+}
+
+sub info_default_menu_link($$$$$$$$)
+{
+ my $entry = shift;
+ my $state = shift;
+ my $href = shift;
+ my $node = shift;
+ my $title = shift;
+ my $ending = shift;
+ my $has_title = shift;
+ my $command_stack = shift;
+ my $preformatted = shift;
+
+ $title = '' unless ($has_title);
+ $title .= ':' if ($title ne '');
+ my $result = "$MENU_SYMBOL$title$node$ending";
+ return info_default_store_text($state,$result,'menu_entry');
+}
+
+#Â not used, menu is a normal preformatted command
+#sub info_default_menu_command($$$)
+#{
+# my $format = shift;
+# my $text = shift;
+# my $in_preformatted = shift;
+#print STDERR "MENU $format\n";
+# return info_default_close_command(undef, $format, "* Menu:\n", undef,
"\n");
+#}
+
+sub info_default_complex_format($$)
+{
+ my $name = shift;
+ my $text = shift;
+ my ($begin, $end);
+ if ($name eq 'menu')
+ {
+ $begin = "* Menu:\n\n";
+ }
+ elsif ($name eq 'direntry')
+ {
+ $begin = "START-INFO-DIR-ENTRY\n";
+ $end = "END-INFO-DIR-ENTRY\n";
+ }
+ return info_default_close_command(undef, $name, $begin, $end);
+}
+
+sub info_default_quotation($$$$)
+{
+ my $command = shift;
+ my $text = shift;
+ my $argument_text = shift;
+ my $argument_text_texi = shift;
+
+ return info_default_close_command(undef, $command);
+}
+
+sub info_default_misc_commands($$$$$)
+{
+ my $command = shift;
+ my $line = shift;
+ my $pass = shift;
+ my $stack = shift;
+ my $state = shift;
+
+ return ($line, 0, undef, undef) unless ($pass == 2);
+ return ($line, 0, undef, undef) unless ($command eq 'exdent' or $command
eq 'noindent' or $command eq 'indent');
+ my ($result_line, $text, $args) = &$preserve_misc_command ($line,
$command);
+ info_default_store_text($state,'',$command);
+ return ($result_line, 1, '', undef);
+}
+
+sub info_default_external_ref($$$$$$$$)
+{
+ my $type = shift;
+ my $section = shift;
+ my $book = shift;
+ my $file_node = shift;
+ my $href = shift;
+ my $cross_ref = shift;
+ my $args_texi = shift;
+ my $formatted_args = shift;
+
+ return info_default_inforef($formatted_args) if ($type eq 'inforef');
+ return info_default_normal_reference($type, $formatted_args);
+}
+
+sub info_default_internal_ref($$$$$$$$)
+{
+ my $type = shift;
+ my $href = shift;
+ my $short_name = shift;
+ my $name = shift;
+ my $is_section = shift;
+ my $args_texi = shift;
+ my $formatted_args = shift;
+ my $element = shift;
+
+ $formatted_args->[1] = $name if ($element->{'float'} and
(!defined($formatted_args->[1]) or $formatted_args->[1] eq ''));
+ return info_default_inforef($formatted_args) if ($type eq 'inforef');
+ return info_default_normal_reference($type, $formatted_args);
+}
+
+sub info_default_normal_reference($$)
+{
+ my $command = shift;
+ my $formatted_args = shift;
+ for (my $i = 0; $i < scalar(@$formatted_args); $i++)
+ {
+ $formatted_args->[$i] = undef if (defined($formatted_args->[$i]) and
+ $formatted_args->[$i] =~ /^\s*$/);
+ }
+ my $node = $formatted_args->[0];
+ my $name = $formatted_args->[1];
+ $name = $formatted_args->[2] if (!defined($name));
+ my $file = $formatted_args->[3];
+ $file = '' if (!defined($file) and defined($formatted_args->[4]));
+ $name = $node if (!defined($name) and defined($file));
+ my $result = '*note ';
+ $result = '*Note ' if ($command eq 'xref');
+ if (defined($name))
+ {
+ $result .= "${name}: ";
+ $result .= "($file)" if (defined($file));
+ $result .= "$node";
+ $result .= '.' if ($command eq 'pxref');
+ }
+ else
+ {
+ $result .= "${node}::";
+ }
+ return $result;
+}
+
+sub info_default_inforef($)
+{
+ my $formatted_args = shift;
+ return info_default_normal_reference('ref', [$formatted_args->[0],
$formatted_args->[1], undef, $formatted_args->[2], 'dumb manual name']);
+}
+
+sub info_default_image_files($$$$)
+{
+ my $base = shift;
+ my $extension = shift;
+ my $texi_base = shift;
+ my $texi_extension = shift;
+ my @files = ();
+ return @files if (!defined($base) or ($base eq ''));
+
+ if (defined($extension) and ($extension ne ''))
+ {
+ push @files, ["${base}$extension", "${texi_base}$extension"];
+ push @files, ["$base.$extension", "$texi_base.$extension"];
+ }
+ foreach my $ext (@IMAGE_EXTENSIONS)
+ {
+ push @files, ["$base.$ext", "$texi_base.$ext"];
+ }
+ return @files;
+}
+
+sub info_default_image($$$$$$$$$$$$$$$$$)
+{
+ my $file = shift;
+ my $base = shift;
+ my $preformatted = shift;
+ my $file_name = shift;
+ my $alt = shift;
+ my $width = shift;
+ my $height = shift;
+ my $raw_alt = shift;
+ my $extension = shift;
+ my $working_dir = shift;
+ my $file_path = shift;
+ my $in_paragraph = shift;
+ my $file_locations = shift;
+ my $base_simple_format = shift;
+ my $extension_simple_format = shift;
+ my $file_name_simple_format = shift;
+ my $line_nr = shift;
+
+ my $txt_path;
+ my $found_file;
+
+ my @extensions = @IMAGE_EXTENSIONS;
+ if (defined($extension) and ($extension ne ''))
+ {
+ unshift @extensions, ".$extension";
+ unshift @extensions, "$extension";
+ }
+ else
+ {
+ $extension = undef;
+ }
+ my $file_found_index = undef;
+ my $file_index = 0;
+ foreach my $file_location (@$file_locations)
+ {
+ my ($file_located, $path, $file_simple_format) = @$file_location;
+ my $extension = shift @extensions;
+ if (defined($path))
+ {
+ if ($extension eq 'txt' and !defined($txt_path))
+ {
+ $txt_path = $path;
+ }
+ elsif (!defined($found_file))
+ {
+ $found_file = [$file_located, $extension, $file_simple_format];
+ $file_found_index = $file_index;
+ }
+ }
+ $file_index++;
+ }
+
+ my $text;
+ if (defined($txt_path))
+ {
+ if (open(TXT, "<$txt_path"))
+ {
+ if (defined($Texi2HTML::THISDOC{'IN_ENCODING'}) and $USE_UNICODE)
+ {
+ binmode(TXT, ":encoding($Texi2HTML::THISDOC{'IN_ENCODING'})");
+ }
+ $text='[' if ($in_paragraph or $preformatted);
+ while (my $img_txt = <TXT>)
+ {
+ $text .= $img_txt;
+ }
+ $text .= ']' if ($in_paragraph or $preformatted);
+ close(TXT);
+ }
+ else
+ {
+ main::echo_warn ("address@hidden file `$txt_path' unreadable: $!",
$line_nr);
+ }
+ }
+ else
+ {
+ main::echo_warn ("Cannot find address@hidden file `$base.txt'",
$line_nr);
+ }
+ if (defined($found_file) and (!defined($extension) or $file_found_index <=
1))
+ {
+ my $filename = $found_file->[2];
+ $filename =~ s/\\/\\\\/g;
+ $filename =~ s/\"/\\\"/g;
+ my $result = "\x{00}\x{08}[image src=\"$filename\"";
+ if (defined($alt))
+ {
+ $alt =~ s/\\/\\\\/g;
+ $alt =~ s/\"/\\\"/g;
+ $result .= " alt=\"$alt\"";
+ }
+ if (defined($text))
+ {
+ $text =~ s/\\/\\\\/g;
+ $text =~ s/\"/\\\"/g;
+ $result .= " text=\"$text\"";
+ }
+ $result .= "\x{00}\x{08}]";
+ return $result;
+ }
+ return $text if (defined($text));
+ return '';
+}
+
+sub info_default_print_index($$)
+{
+ my $text = shift;
+ my $name = shift;
+ my $state = $Texi2HTML::THISDOC{'state'};
+ my $info_state = info_default_get_state ($state);
+ my $before = '';
+ if (!$info_state->{'blank_line'})
+ {
+ $before = "\n";
+ $info_state->{'offset_in_file'} += length($before);
+ $info_state->{'line_count'}++;
+ $info_state->{'blank_line'} = 1;
+ }
+ return $before if (!defined($text));
+ my $result = "\x{00}\x{08}[index\x{00}\x{08}]\n* Menu:\n\n" .$text."\n";
+ $info_state->{'offset_in_file'} += length($result);
+
+ my ($line_passed, $end_of_line, $last_line, $text_indented, $blank_line) =
info_default_count_lines($result);
+ $info_state->{'blank_line'} = 1 if (($last_line !~ /\S/ and $end_of_line)
or ($blank_line));
+ $info_state->{'line_count'} += $line_passed;
+ return $before.$result;
+}
+
+sub info_default_index_letter($$$)
+{
+ my $letter = shift;
+ my $id = shift;
+ my $text = shift;
+ return $text;
+}
+
+sub info_default_index_entry_label($$$$$$$$)
+{
+ my $identifier = shift;
+ my $preformatted = shift;
+ my $entry = shift;
+ my $index_name = shift;
+ my $index_command = shift;
+ my $texi_entry = shift;
+ my $formatted_entry = shift;
+ my $index_entry_ref = shift;
+
+ my $state = $Texi2HTML::THISDOC{'state'};
+ my $info_state = info_default_get_state($state);
+ print STDERR "Storing index entry $formatted_entry\n";
+ my $index_entry_stored = {'command' => 'index_label',
'index_entry_reference' => $index_entry_ref, 'index_command' => $index_command,
'index_name' => $index_name};
+ push @{$info_state->{'current'}->{'content'}}, $index_entry_stored;
+ return info_default_output($info_state)
+ if (!defined($info_state->{'current'}->{'command'}));
+ return '';
+}
+
+sub info_default_index_entry($$$$$$$$)
+{
+ my $text_href = shift;
+ my $entry = shift;
+ my $element_href = shift;
+ my $element_text = shift;
+ my $entry_file = shift;
+ my $current_element_file = shift;
+ my $entry_target = shift;
+ my $entry_element_target = shift;
+ my $index_entry_ref = shift;
+
+ return '' if ($index_entry_ref->{'hidden'});
+ $entry = main::substitute_line($index_entry_ref->{'texi'}, "index entry in
address@hidden");
+
+ my $result = "* $entry: ";
+ if (length($result) < $info_default_index_length_to_node)
+ {
+ $result .= ' ' x($info_default_index_length_to_node - length($result));
+ }
+ my $element = $index_entry_ref->{'real_element'};
+ $element = $element->{'element_ref'} if ($element->{'element_ref'});
+ $result .= $element->{'text'} . '.';
+ my $info_index_entry_ref = $info_default_index_entries{$index_entry_ref};
+ my $line_nr = $info_index_entry_ref->{'line_nr'};
+ #Â this happens for index entries appearing after @printindex. In that case
+ #Â it is consideered that they are at the beginning of the node.
+ $line_nr = 4 if (!defined($line_nr) or $line_nr < 4);
+ my $max_len =
$info_default_index_line_string_length{$info_index_entry_ref->{'index_name'}};
+ my $line_nr_spaces = sprintf("%${max_len}d", $line_nr);
+ my $line_part = "(line ${line_nr_spaces})";
+#print STDERR "GGGGGGGGGG name: $info_index_entry_ref->{'index_name'} max:
${max_len} line_nr: `$line_nr' line_nr_spaces `$line_nr_spaces' $line_part \n";
+ if (length($result)+length($line_part) +1 > get_conf('fillcolumn'))
+ {
+ $result .= "\n" . ' ' x (get_conf('fillcolumn') - length($line_part)) ;
+ }
+ else
+ {
+ $result .= ' ' x (get_conf('fillcolumn') - length($line_part) -
length($result));
+ }
+ $result .= "$line_part\n";
+
+ return $result;
+}
+
+sub info_default_index_summary($$)
+{
+ my $alpha = shift;
+ my $nonalpha = shift;
+
+ return '';
+}
+
+sub info_default_summary_letter
+{
+ return '';
+}
+
+sub info_default_foot_line_and_ref($$$$$$$$)
+{
+ my $foot_num = shift;
+ my $relative_num = shift;
+ my $footid = shift;
+ my $docid = shift;
+ my $from_file = shift;
+ my $footnote_file = shift;
+ my $lines = shift;
+ my $state = shift;
+
+ my $footnote_state = $Texi2HTML::THISDOC{'state'};
+ my $footnote_info_state = info_default_get_state ($footnote_state);
+
+ my $footnote_text = "($info_default_footnote_index)";
+ my $node_name;
+ $node_name = '';
+ $node_name = $info_default_current_node->{'text'} if
defined($info_default_current_node);
+ if (get_conf('footnotestyle') eq 'separate')
+ {
+ $footnote_text .= ' (' . info_default_normal_reference('pxref',
["${node_name}-Footnote-${info_default_footnote_index}"]) . ')';
+ }
+ push @info_default_pending_footnotes, {'lines' => $lines,
+ 'footnote_text' => $footnote_text,
+ 'footnote_index' => ${info_default_footnote_index},
+ 'node_name' => $node_name,
+ 'footnote_info_state' => $footnote_info_state};
+ return ($lines, $footnote_text);
+}
+
+sub info_default_foot_lines($)
+{
+ my $lines = shift;
+ #my $state = $Texi2HTML::THISDOC{'state'};
+ #my $info_state = info_default_get_state ($state);
+ @$lines = ();
+}
+
+#Â remark: table_item is the html one, but it gets added to the table text
+#Â on the stack, and is ignored there (in info_default_format).
+sub info_default_format_list_item_texi($$$$)
+{
+ my $format = shift;
+ my $line = shift;
+ my $prepended = shift;
+ my $command = shift;
+ my $number = shift;
+
+ my $open_command = 0;
+ my $result_line;
+ $command = 'bullet' if ((!defined($command) or $command eq '') and
(!defined($prepended) or $prepended eq '') and $format eq 'itemize');
+ $prepended = "address@hidden" if (defined($command) and $command ne '');
+ $prepended = "$number." if (defined($number) and $number ne '');
+
+ if (defined($command) and $command ne '' and $format ne 'itemize')
+ {
+ address@hidden
+ #info_default_begin_style_texi($command, $Texi2HTML::THISDOC{'state'},
undef, undef);
+ #$open_command = 1;
+ $line =~ s/^\s*//;
+ $line =~ s/\s*$//;
+ if (exists ($style_map{$command}))
+ {
+ $result_line = "address@hidden";
+ }
+ elsif (exists ($things_map{$command}))
+ {
+ $result_line = "address@hidden $line\n";
+ }
+ else
+ {
+ $result_line = "address@hidden $line\n";
+ }
+ }
+ elsif (defined($prepended) and $prepended ne '')
+ {
+ $prepended =~ s/^\s*//;
+ $prepended =~ s/\s*$//;
+ $line =~ s/^\s*//;
+ $result_line = $prepended . ' ' . $line;
+ }
+
+ return ($result_line, $open_command);
+}
+
+sub info_default_list_item($$$$$$$$$$$)
+{
+ my $text = shift;
+ my $format = shift;
+ my $command = shift;
+ my $formatted_command = shift;
+ my $item_nr = shift;
+ my $enumerate_style = shift;
+ my $number = shift;
+ my $prepended = shift;
+ my $prepended_formatted = shift;
+ my $only_inter_item_commands = shift;
+ my $before_items = shift;
+
+# my $prepend = '';
+# if (defined($formatted_command) and $formatted_command ne '')
+# {
+# $prepend = $formatted_command;
+# }
+# return $prepend . $text;
+ return $text;
+}
+
+sub info_default_format($$$)
+{
+ my $tag = shift;
+ my $element = shift;
+ my $text = shift;
+
+ # currently no command has something else than '' as $element.
+ # notice that any text is discarded
+ $element = undef if ($element eq '');
+ my $element_end = $element;
+ if (defined($element) and $element =~ /^(\w+)(\s+)(.+)/)
+ {
+ $element = $1;
+ $element_end = $2;
+ }
+ return info_default_close_command(undef, $tag, $element, $element_end);
+}
+
+sub info_default_tab_item_texi($$$$$$)
+{
+ my $command = shift;
+ my $commands_stack = shift;
+ my $stack = shift;
+ my $state = shift;
+ my $line = shift;
+ my $line_nr = shift;
+
+ my $format;
+ $format = $commands_stack->[-1] if (defined($commands_stack) and
@$commands_stack and $commands_stack->[-1]);
+print STDERR "tab_item_texi $command $commands_stack, $stack, $state, $line,
$line_nr\n";
+ if ($format eq 'multitable')
+ {
+ if ($command ne 'tab')
+ {
+ info_default_open_command($state, 'multitable_row');
+ }
+ info_default_open_command($state, 'multitable_cell');
+ }
+ else
+ {
+ info_default_store_text ($state, '', $command, {'format_name' =>
$format});
+ }
+ $line =~ s/^\s*//;
+ return $line;
+}
+
+sub info_default_sp($$)
+{
+ my $number = shift;
+ my $preformatted = shift;
+ my $result = "\n" x $number;
+ return info_default_store_text(undef,$result,'sp');
+}
+
+sub info_default_paragraph_style_command($$)
+{
+ my $format = shift;
+ my $text = shift;
+ return info_default_close_command(undef, $format);
+}
+
+sub info_default_row($$$$$$$$)
+{
+ my $text = shift;
+ my $macro = shift;
+ my $columnfractions = shift;
+ my $prototype_row = shift;
+ my $prototype_lengths = shift;
+ my $column_number = shift;
+ my $only_inter_item_commands = shift;
+ my $before_items = shift;
+
+ return info_default_close_command(undef, 'multitable_row', undef, undef,
{'item_command' => $macro});
+}
+
+sub info_default_cell($$$$$$$$)
+{
+ my $text = shift;
+ my $row_macro = shift;
+ my $columnfractions = shift;
+ my $prototype_row = shift;
+ my $prototype_lengths = shift;
+ my $column_number = shift;
+ my $only_inter_item_commands = shift;
+ my $before_items = shift;
+
+ return info_default_close_command(undef, 'multitable_cell');
+}
+
+sub info_default_table_list($$$$$$$$$)
+{
+ my $format_command = shift;
+ my $text = shift;
+ my $command = shift;
+ my $formatted_command = shift;
+# enumerate
+ my $item_nr = shift;
+ my $enumerate_style = shift;
+# itemize
+ my $prepended = shift;
+ my $prepended_formatted = shift;
+# multitable
+ my $columnfractions = shift;
+ my $prototype_row = shift;
+ my $prototype_lengths = shift;
+ my $column_number = shift;
+
+ return info_default_close_command(undef, $command) if ($format_command ne
'multitable');
+
+ my $columnsize = [];
+ if (defined($prototype_lengths) and @$prototype_lengths)
+ {
+ $columnsize = [ @$prototype_lengths ];
+ }
+ elsif (defined($columnfractions) and @$columnfractions)
+ {
+ foreach my $fraction (@$columnfractions)
+ {
+ push @$columnsize, int($fraction * get_conf('fillcolumn') +0.5);
+ }
+ }
+ else
+ {
+ print STDERR "Empty multitable?\n";
+ }
+
+ return info_default_close_command(undef, $format_command, undef, undef,
{'columns_size' => $columnsize});
+}
+
+sub info_default_def_item($$$)
+{
+ my $text = shift;
+ my $only_inter_item_commands = shift;
+ my $command = shift;
+
+ my $format = 'deff_item';
+ $format = 'deff_itemx' if ($command =~ /x$/);
+ print STDERR "LLLLLLLLLLLLLL $format $command\n";
+ return info_default_close_command(undef, $format);
+}
+
+sub info_default_def_line($$$$$$$$$$$$$$$$)
+{
+ my $category_prepared = shift;
+ my $name = shift;
+ my $type = shift;
+ my $arguments = shift;
+ my $index_label = shift;
+ my $arguments_array = shift;
+ my $arguments_type_array = shift;
+ my $unformatted_arguments_array = shift;
+ my $command = shift;
+ my $class_name = shift;
+ my $category = shift;
+ my $class = shift;
+ my $style = shift;
+ my $original_command = shift;
+
+ $name = '' if (!defined($name) or ($name =~ /^\s*$/));
+ $type = '' if (!defined($type) or $type =~ /^\s*$/);
+ $arguments = '' if (!defined($arguments) or $arguments =~ /^\s*$/);
+
+ my $type_name = '';
+ $type_name .= "$type " if ($type ne '');
+ $type_name .= $name if ($name ne '');
+
+ my $result = " -- $category_prepared: ${type_name}$arguments";
+ $result =~ s/\s*$//;
+ $result .= "\n";
+ my $state = $Texi2HTML::THISDOC{'state'};
+# if ($command =~ /x$/)
+# {
+ info_default_store_text(undef,$result,"${command}_line",{'definition_line'
=> 1});
+# }
+# else
+# {
+# return info_default_open_command($state, $command, {'begin'=>$result});
+# }
+ my $format = 'deff_item';
+ $format = 'deff_itemx' if ($original_command =~ /x$/);
+ print STDERR "JJJJJJJJJJJJJ $command GGG $original_command $format\n";
+ return info_default_open_command($state, $format);
+}
+
+sub info_default_def($$)
+{
+ my $text = shift;
+ my $command = shift;
+ return info_default_close_command(undef, $command);
+}
+
+sub info_default_float($$$$$)
+{
+ my $text = shift;
+ my $float = shift;
+ my $caption = shift;
+ my $shortcaption = shift;
+
+ my $additional_arguments;
+ if (exists($float->{'id'}))
+ {
+ $additional_arguments->{'anchor_reference'} = $float;
+ }
+ my $caption_text = '';
+
+ if (defined($float->{'caption_texi'}))
+ {
+ $caption_text = $caption;
+ }
+ elsif (defined($float->{'shortcaption_texi'}))
+ {
+ $caption_text = $shortcaption;
+ }
+ elsif (defined($caption))
+ {
+ $caption_text = $caption;
+ }
+
+ #return $caption_text;
+ return info_default_close_command(undef, 'float', undef, $caption_text,
$additional_arguments);
+}
+
+sub info_default_listoffloats_entry($$$$)
+{
+ my $style_texi = shift;
+ my $float = shift;
+ my $float_style = shift;
+ my $caption = shift;
+ my $href = shift;
+
+ my @lines = split /^/, $caption;
+ $caption = $lines[0];
+ chomp ($caption);
+
+ my $result = '';
+ $caption .= ':' if ($caption ne '');
+ my $caption_entry = "* $float_style: $caption";
+ my $length = 0;
+ while ($caption_entry =~ s/^(\S+\s*)//)
+ {
+print STDERR "CAPTION_ENTRY($length) $caption_entry\n";
+ my $new_word = $1;
+ if (length($new_word) + $length >
($info_default_listoffloat_caption_entry_length - 3) or (length($new_word) +
$length + length($info_default_listoffloat_append) >
$info_default_listoffloat_caption_entry_length and $caption_entry ne ''))
+ {
+ $result .= $info_default_listoffloat_append;
+ last;
+ }
+ else
+ {
+ $result .= $new_word;
+ $length += length($new_word);
+ }
+ }
+print STDERR "RESULT `$result'\n";
+ $result .= ' ' x ($info_default_listoffloat_caption_entry_length -
length($result));
+print STDERR "RESULT `$result'\n";
+
+ return "${result}$float->{'text'}.\n";
+}
+
+sub info_default_listoffloats($$$)
+{
+ my $style_texi = shift;
+ my $style = shift;
+ my $float_entries = shift;
+
+ my $state = $Texi2HTML::THISDOC{'state'};
+ my $info_state = info_default_get_state ($state);
+ my $result = "* Menu:\n\n";
+ foreach my $float_entry (@$float_entries)
+ {
+ $result .= $float_entry;
+ }
+ my ($parent_format, $in_format);
+ ($parent_format, $in_format) =
info_default_parent_format($info_state->{'current'});
+#print STDERR "JJJJJJJJJJj listoffloats not in top\n" if ($in_format);
+ $info_state->{'paragraph_in_element_nr'}++ if (!$in_format);
+ return info_default_store_text($state,$result,'listoffloats');
+}
+
+sub info_default_raw($$)
+{
+ my $style = shift;
+ my $text = shift;
+ my $expanded = 1 if (grep {$style eq $_} @EXPAND);
+ if ($style eq 'verbatim' or $style eq 'verbatiminclude' or $expanded)
+ {
+ return info_default_store_text(undef,$text, $style);
+ }
+# if ($style eq 'direntry')
+# {
+# $info_default_dir_specification .= "START-INFO-DIR-ENTRY\n"
+# .$text. "END-INFO-DIR-ENTRY\n";
+# }
+ return '';
+}
+
+sub info_default_line_command($$$$)
+{
+ my $command = shift;
+ my $arg_text = shift;
+ my $arg_texi = shift;
+ my $state = shift;
+
+ return '' if ($arg_text eq '');
+ $info_default_dir_specification .= "INFO-DIR-SECTION $arg_text\n";
+ return '';
+}
+
+#Â info is special, since it doesn't use the basename but directly the
+#Â setfilename output, contrary to all the other formats
+sub info_default_element_file_name($$$)
+{
+ my $element = shift;
+ my $type = shift;
+ my $prefix = shift;
+
+ my $outname;
+ $outname = $OUT if (defined($OUT) and $OUT ne '' and $OUT !~ /\/$/ and
$Texi2HTML::THISDOC{'input_file_number'} == 0);
+ if ($type eq 'doc')
+ {
+ if (defined($Texi2HTML::THISDOC{'setfilename'}) and !defined($outname))
+ {
+ $Texi2HTML::THISDOC{'extension'} = '';
+ return $Texi2HTML::THISDOC{'setfilename'};
+ }
+ }
+
+ return undef;
+}
+
+1;
Index: formats/xml.init
===================================================================
RCS file: formats/xml.init
diff -N formats/xml.init
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ formats/xml.init 22 May 2009 18:50:30 -0000 1.1
@@ -0,0 +1,1235 @@
+use strict;
+
+my @xml_multitable_stack = ();
+my @xml_table_stack = ();
+
+my @xml_ignored_misc_commands;
+my %xml_misc_elements_with_arg_map;
+my @xml_misc_elements_with_arg;
+my %def_format_xml;
+
+sub xml_default_load()
+{
+
+$EXTENSION = "xml";
+$DOCTYPE = '<!DOCTYPE texinfo PUBLIC "-//GNU//DTD TexinfoML V4.12//EN"
"http://www.gnu.org/software/texinfo/dtd/4.12/texinfo.dtd">';
+$USE_MENU_DIRECTIONS = 0;
+$USE_UP_FOR_ADJACENT_NODES = 0;
+$USE_NUMERIC_ENTITY = 0;
+$USE_SETFILENAME = 1;
+$SEPARATE_DESCRIPTION = 1;
+$USE_NODES = 1;
address@hidden = ('xml', 'direntry');
+
+$USE_ISO = 0;
+$SECTION_NAVIGATION = 0;
+
+push @Texi2HTML::Config::command_handler_process, \&xml_init_variables;
+
+$colon_command_punctuation_characters{'.'} = '.';
+$colon_command_punctuation_characters{':'} = ':';
+$colon_command_punctuation_characters{'?'} = '?';
+$colon_command_punctuation_characters{'!'} = '!';
+
+$simple_map{'*'} = '&linebreak;';
+$simple_map{' '} = '&space;';
+$simple_map{"\t"} = '&space;';
+$simple_map{"\n"} = '&space;';
+$simple_map{'.'} = '&eosperiod;';
+$simple_map{'!'} = '&eosexcl;';
+$simple_map{'?'} = '&eosquest;';
+
+%simple_map_pre = %simple_map;
+
+# FIXME right?
+$things_map{'l'} = '/l';
+$things_map{'L'} = '/L';
+$things_map{'enddots'} = '&enddots;';
+$things_map{'dots'} = '&dots;';
+# FIXME ≡
+#$things_map{'equiv'} = '==';
+$things_map{'minus'} = '−';
+$things_map{'result'} = '⇒';
+$things_map{'bullet'} = '•';
+$things_map{'copyright'} = '©right;';
+$things_map{'registeredsymbol'} = '®istered;';
+$things_map{'arrow'} = '→';
+$things_map{'TeX'} = '&tex;';
+$things_map{'LaTeX'} = '&latex;';
+
+%pre_map = %things_map;
+
+$stop_paragraph_command{'caption'} = 1;
+$stop_paragraph_command{'shortcaption'} = 1;
+
+%line_command_map = ();
+
+$format_map{'copying'} = '';
+$format_map{'titlepage'} = 'titlepage';
+$format_map{'documentdescription'} = 'documentdescription';
+$format_map{'group'} = 'group';
+
+foreach my $region ('titlepage', 'documentdescription', 'copying')
+{
+ $region_formats_kept{$region} = 1;
+}
+
+foreach my $style (keys(%style_map))
+{
+ next if grep {$style eq $_} ('asis', 'ctrl', 'w', 'tieaccent', 'dotless',
keys(%unicode_accents));
+ if (!exists($style_map{$style}->{'args'}) or
(scalar(@{$style_map{$style}->{'args'}}) eq 1 and
$style_map{$style}->{'args'}->[0] eq 'code'))
+ {
+ $style_map{$style}->{'attribute'} = $style;
+ delete ($style_map{$style}->{'quote'});
+ delete ($style_map{$style}->{'begin'});
+ delete ($style_map{$style}->{'end'});
+ }
+}
+
+foreach my $complex_format (keys(%$complex_format_map))
+{
+ my $style = $complex_format_map->{$complex_format}->{'style'};
+ delete $complex_format_map->{$complex_format};
+ $complex_format_map->{$complex_format}->{'begin'} = "\"<$complex_format
xml:space=\\\"preserve\\\">\"";
+ $complex_format_map->{$complex_format}->{'end'} = "\"</$complex_format>\"";
+ $complex_format_map->{$complex_format}->{'style'} = $style if
(defined($style));
+}
+foreach my $menu_command('menu', 'detailmenu', 'direntry', 'menu_comment')
+{
+ $complex_format_map->{$menu_command} = undef;
+ delete $complex_format_map->{$menu_command};
+}
+
+delete $iso_symbols{'`'};
+delete $iso_symbols{"'"};
+delete $style_map{'verb'}->{'attribute'};
+$style_map{'indicateurl'}->{'attribute'} = 'url';
+$style_map{'w'}->{'end'} = '<!-- /@w -->';
+$style_map{'='}->{'function'} = \&xml_macron;
+$style_map{'email'}->{'function'} = \&xml_email;
+$style_map{'titlefont'}->{'function'} = \&xml_titlefont;
+$style_map{'math'}->{'function'} = \&xml_math;
+$style_map{'uref'}->{'function'} = \&xml_uref;
+$style_map{'url'}->{'function'} = \&xml_uref;
+$style_map{'t'}->{'attribute'} = 'tt';
+# FIXME
+delete $special_accents{'ringaccent'};
+$special_accents{'ogonek'} = 'aeiuAEIU';
+
+%style_map_pre = %style_map;
+
+$no_paragraph_commands{'cindex'} = 0;
+
+#my @xml_ignored_misc_commands = ('bye', 'sp', 'verbatiminclude');
+
address@hidden = ('bye', 'sp', 'verbatiminclude', 'clickstyle',
+ 'defcodeindex',
+ 'syncodeindex', 'paragraphindent', 'shorttitlepage', 'refill', 'noindent');
+
+# we want to proceed all the misc commands
+# makeinfo ignores clickstyle, changes setfilename. Not sure it is right.
+foreach my $misc_command (keys(%misc_command))
+{
+ next if (grep {$misc_command eq $_} @xml_ignored_misc_commands);
+ $misc_command{$misc_command}->{'keep'} = 1;
+}
+
+$format_map{'menu'} = 'menu';
+# checked on bug-texinfo, only node is in code_style, as with makeinfo --xml
+#$format_code_style{'menu'} = 1;
+#$format_code_style{'menu_name'} = 1;
+#$format_code_style{'menu_description'} = 1;
+$format_map{'detailmenu'} = 'detailmenu';
+$format_map{'direntry'} = 'direntry';
+$format_map{'menu_comment'} = '';
+delete $format_map{'enumerate'};
+foreach my $table ('table', 'ftable', 'vtable')
+{
+ #$format_map{$table} = 'table';
+ delete $format_map{$table};
+}
+
+$menu_description = \&xml_menu_description;
+$menu_link = \&xml_menu_link;
+$element_heading = \&xml_heading;
+$heading = \&xml_heading;
+$heading_texi = \&xml_heading_texi;
+$paragraph = \&xml_paragraph;
+$preformatted = \&xml_preformatted;
+$misc_element_label = \&xml_noop;
+$element_label = \&xml_noop;
+$anchor_label = \&xml_anchor_label;
+$index_entry_label = \&xml_index_entry_label;
+$index_entry_command = \&xml_index_entry_command;
+$listoffloats = \&xml_listoffloats;
+$acronym_like = \&xml_acronym_like;
+$foot_line_and_ref = \&xml_foot_line_and_ref;
+$image = \&xml_image;
+$sp = \&xml_sp;
+$quotation = \&xml_quotation;
+$table_list = \&xml_table_list;
+$row = \&xml_row;
+$cell = \&xml_cell;
+$list_item = \&xml_list_item;
+$format_list_item_texi = \&xml_format_list_item_texi;
+$unknown = \&xml_misc_commands;
+$begin_format_texi = \&xml_begin_format_texi;
+$def_line = \&xml_def_line;
+$def = \&xml_def;
+$def_item = \&xml_def_item;
+$printindex = \&xml_printindex;
+$index_summary = \&xml_index_summary;
+$external_ref = \&xml_external_ref;
+$internal_ref = \&xml_internal_ref;
+$table_item = \&xml_table_item;
+$table_line = \&xml_table_line;
+$float = \&xml_float;
+$caption_shortcaption = \&xml_caption_shortcaption;
+$caption_shortcaption_command = \&xml_caption_shortcaption_command;
+$normal_text = \&xml_normal_text;
+$paragraph_style_command = \&xml_paragraph_style_command;
+$raw = \&xml_raw;
+$cartouche = \&xml_cartouche;
+
+$print_Top = \&xml_print_Top;
+$print_Top_footer = \&xml_print_Top_footer;
+$print_page_head = \&xml_print_page_head;
+#$print_navigation = \&xml_noop;
+$print_foot_navigation = \&xml_noop;
+$toc_body = \&xml_noop;
+$about_body = \&xml_noop;
+$print_page_foot = \&xml_print_page_foot;
+$end_section = \&xml_end_section;
+$one_section = \&xml_one_section;
+
+%xml_misc_elements_with_arg_map = (
+ 'title' => 'booktitle',
+ 'subtitle' => 'booksubtitle'
+);
+
address@hidden = ('author',
+ 'dircategory', 'settitle');
+#my @xml_misc_elements_with_arg = ('author', 'shorttitlepage',
+# 'vskip', 'dircategory', 'settitle');
+
+%def_format_xml = (
+ 'deffn' => [ ['category', 'category'], ['function', 'name'] ],
+ 'defvr' => [ ['category', 'category'], ['variable', 'name'] ],
+ 'deftypefn' => [ ['category', 'category'], ['type', 'type'], ['function',
'name'] ],
+ 'deftypeop' => [ ['category', 'category'], ['type', 'type'], ['operation',
'name'] ],
+ 'deftypevr' => [ ['category', 'category'], ['type', 'type'], ['variable',
'name'] ],
+ 'defcv' => [ ['category' , 'category'], ['class', 'class'], ['classvar',
'name'] ],
+ 'deftypecv' => [ ['category', 'category'], ['type', 'type'], ['classvar',
'name'] ],
+ 'defop' => [ ['category', 'category'], ['class', 'class'], ['operation',
'name'] ],
+ 'deftp' => [ ['category', 'category'], ['datatype', 'name'] ]
+);
+
+
+}
+
+sub xml_macron($$)
+{
+ my $accent = shift;
+ my $args = shift;
+ return $args->[0] . "¯";
+}
+
+sub xml_email($$)
+{
+ my $command = shift;
+ my $args = shift;
+ my $mail = shift @$args;
+ my $text = shift @$args;
+ $mail = main::normalise_space($mail);
+ my $result = "<email><emailaddress>$mail</emailaddress>";
+ if (defined($text) and $text =~ /\S/)
+ {
+ $result .= "<emailname>".main::normalise_space($text)."</emailname>";
+ }
+ return $result . '</email>';
+}
+
+sub xml_uref($$)
+{
+ shift;
+ my $args = shift;
+ my $url = shift @$args;
+ my $text = shift @$args;
+ my $replacement = shift @$args;
+ $url = main::normalise_space($url);
+ $replacement = '' if (!defined($replacement));
+ $replacement = main::normalise_space($replacement);
+ $text = '' if (!defined($text));
+ $text = main::normalise_space($text);
+ my $result = "<uref><urefurl>$url</urefurl>";
+ $result .= "<urefdesc>$text</urefdesc>" if ($text ne '');
+ $result .= "<urefreplacement>$replacement</urefreplacement>" if
($replacement ne '');
+ return $result.'</uref>';
+}
+
+
+sub xml_titlefont($$)
+{
+ shift;
+ my $args = shift;
+ return "<titlefont>$args->[0]</ititlefont>" if ($args->[0] =~ /\S/);
+ return '';
+}
+
+sub xml_math($$)
+{
+ shift;
+ my $args = shift;
+ my $text = shift @$args;
+ $text =~ s/[{}]//g;
+ return "<math>$text</math>";
+}
+
+
+sub xml_menu_description($$$)
+{
+ my $text = shift;
+ my $state = shift;
+ my $element_text = shift;
+ return "<menucomment>$text</menucomment>\n</menuentry>";
+}
+
+sub xml_menu_link($$$$$$$)
+{
+ my $entry = shift;
+ my $state = shift;
+ my $href = shift;
+ my $menunode = shift;
+ my $menutitle = shift;
+ my $ending = shift;
+ my $has_title = shift;
+
+ return
"<menuentry>\n<menunode>$menunode</menunode>\n<menutitle>$menutitle</menutitle>\n";
+}
+
+sub xml_print_page_head($)
+{
+ my $fh = shift;
+ my $setfilename = '';
+ $setfilename =
"<setfilename>$Texi2HTML::THISDOC{file_base_name}.$EXTENSION</setfilename>"
+ unless (defined($Texi2HTML::THISDOC{'setfilename'}) and
$Texi2HTML::THISDOC{'setfilename'} ne '');
+ my $language = get_conf('documentlanguage');
+ print $fh <<EOT;
+<?xml version="1.0"?>
+$DOCTYPE
+<texinfo xml:lang="$language">
+$setfilename
+EOT
+}
+
+sub xml_print_page_foot($)
+{
+ my $fh = shift;
+ print $fh <<EOT;
+</texinfo>
+<!-- Keep this comment at the end of the file
+Local variables:
+mode: sgml
+sgml-indent-step:1
+sgml-indent-data:nil
+End:
+-->
+EOT
+}
+
+sub xml_heading_texi($$$)
+{
+ my $tag = shift;
+ my $texi = shift;
+ my $number = shift;
+ $texi =~ s/\s*$//;
+ $texi =~ s/^\s*//;
+ return $texi;
+}
+
+sub xml_one_section($$)
+{
+ my $fh = shift;
+ my $element = shift;
+ main::print_lines($fh);
+ print $fh "". xml_footing($element);
+ &$print_foot_navigation($fh);
+ &$print_page_foot($fh);
+}
+
+sub xml_heading($$$$$)
+{
+ my $element = shift;
+ my $command = shift;
+ my $texi_line = shift;
+ my $line = shift;
+ my $in_preformatted = shift;
+
+#print STDERR "'$command' $line";
+ if (defined($command) and $command =~ /heading/)
+ {
+ my $text = '';
+ if (defined($line))
+ {
+ $text = $line;
+ # this isn't done in main program in that case...
+ chomp ($text);
+ $text =~ s/^\s*//;
+ }
+ return "<${command}>$text</${command}>\n";
+ }
+
+ my $node_element;
+ if ($element->{'node'})
+ {
+ $node_element = $element;
+ }
+ elsif (defined($element->{'node_ref'}))
+ {
+ $node_element = $element->{'node_ref'};
+ }
+
+ my $result = '';
+ if (defined($node_element) and $command eq 'node')
+ {
+#print STDERR "node $command $node_element->{'texi'}\n";
+ $result .= "<node>\n";
+ $result .= "<nodename>$node_element->{'text'}</nodename>\n";
+ foreach my $direction('nodenext', 'nodeprev', 'nodeup')
+ {
+ if ($node_element->{$direction})
+ {
+ $result .=
"<${direction}>$node_element->{$direction}->{'text'}</${direction}>\n";
+ }
+ }
+ }
+
+ if (!$element->{'node'})
+ {
+ my $class = $element->{'tag_level'};
+ # FIXME wrong?
+ $class = 'unnumbered' if ($class eq 'top' or $class eq 'centerchap');
+ $result .= "<${class}>\n<title>$element->{'text'}</title>\n";
+ }
+ return $result;
+}
+
+sub xml_footing($)
+{
+ my $element = shift;
+
+ my $result = '';
+ if (!$element->{'node'})
+ {
+ my $class = $element->{'tag_level'};
+ # FIXME wrong?
+ $class = 'unnumbered' if ($class eq 'top' or $class eq 'centerchap');
+ $result .= "</${class}>\n";
+ }
+ if ($element->{'node'} or defined($element->{'node_ref'}))
+ {
+ $result .= "</node>\n";
+ }
+ return $result;
+}
+
+sub xml_end_section($$$)
+{
+ my $fh = shift;
+ my $end_foot_navigation = shift;
+ my $element = shift;
+ print $fh "". xml_footing($element);
+}
+
+sub xml_print_Top($$$)
+{
+ my $fh = shift;
+ my $has_top_heading = shift;
+ my $element = shift;
+ #print $fh "".xml_heading($element);
+ main::print_lines($fh, $Texi2HTML::THIS_SECTION);
+}
+
+sub xml_print_Top_footer($$)
+{
+ my $fh = shift;
+ my $end_page = shift;
+ my $element = shift;
+
+ print $fh "". xml_footing($element);
+}
+
+# FIXME warning:
+#
+# @code{first para
+#
+# second para}.
+#
+# leads to:
+# <para><code>first para second para</code>.</para>
+sub xml_paragraph($$$$$$$$$$$$)
+{
+ my $text = shift;
+ my $align = shift;
+ my $indent = shift;
+ my $paragraph_command = shift;
+ my $paragraph_command_formatted = shift;
+ my $paragraph_number = shift;
+ my $format = shift;
+ my $item_nr = shift;
+ my $enumerate_style = shift;
+ my $number = shift;
+ my $command_stack_at_end = shift;
+ my $command_stack_at_begin = shift;
+
+ foreach my $style(t2h_collect_styles($command_stack_at_begin))
+ {
+ $text = t2h_begin_style($style, $text);
+ }
+ foreach my $style(t2h_collect_styles($command_stack_at_end))
+ {
+ $text = t2h_end_style($style, $text);
+ }
+
+ # no para in multitables, caption and shortcaptions.
+ my $top_stack = '';
+ $top_stack = $command_stack_at_begin->[-1] if (scalar
(@$command_stack_at_begin));
+ return $text if ($top_stack eq 'multitable' or $top_stack eq
'shortcaption' or $top_stack eq 'caption' or $top_stack eq
'documentdescription');
+
+ if ($text =~ /\S/)
+ {
+ return "<para>$text</para>";
+ }
+ return $text;
+}
+
+sub xml_preformatted($$$$$$$$$$$$)
+{
+ my $text = shift;
+ my $pre_style = shift;
+ my $class = shift;
+ my $leading_command = shift;
+ my $leading_command_formatted = shift;
+ my $preformatted_number = shift;
+ my $format = shift;
+ my $item_nr = shift;
+ my $enumerate_style = shift;
+ my $number = shift;
+ my $command_stack_at_end = shift;
+ my $command_stack_at_begin = shift;
+
+ return $text;
+}
+
+sub xml_misc_commands($$$$$)
+{
+ my $macro = shift;
+ my $line = shift;
+ my $pass = shift;
+ my $stack = shift;
+ my $state = shift;
+#print STDERR "$macro $pass $line";
+ return ($line, 0, undef, undef) unless ($pass == 2);
+ return ($line, 0, undef, undef) unless defined($misc_command{$macro});
+
+ my $value_name = '';
+ my $value = '';
+ if ($macro eq 'set' or $macro eq 'clear')
+ {
+ my $value_line = $line;
+ if ($value_line =~ s/^\s+([\w\-]+)//)
+ {
+ $value_name = $1;
+ if ($macro eq 'set')
+ {
+ $value = $value_line;
+ chomp ($value);
+ $value =~ s/^\s*//;
+ }
+ }
+ }
+ my ($result_line, $text, $args) = &$preserve_misc_command ($line, $macro);
+#print STDERR "$macro $pass $line";
+#print STDERR "ARGS @$args\n" if defined ($args);
+ my $result_text = "<${macro}></${macro}>";
+ if ($macro eq 'set' or $macro eq 'clear')
+ {
+ $result_text = "<${macro}value
name=\"$value_name\">$value</${macro}value>\n";
+ }
+ if ($macro eq 'c' or $macro eq 'comment' and scalar(@$args))
+ {
+ my $comment_line = $args->[0];
+ chomp ($comment_line);
+ # makeinfo remove all the leading spaces
+ $comment_line =~ s/^\s//;
+ $result_text = &$comment ($comment_line);
+ }
+ if ($macro eq 'frenchspacing')
+ {
+ my $value = $args->[0];
+ $value =~ s/\s*//g;
+ $result_text = "<${macro} var=\"$value\"></${macro}>";
+ }
+ if (grep {$macro eq $_} @xml_misc_elements_with_arg)
+ {
+ my $arg = $args->[0];
+ $arg =~ s/^\s*//;
+ chomp($arg);
+ $result_text = "<${macro}>".main::substitute_line($arg,
"address@hidden")."</${macro}>\n";
+ }
+ if (exists($xml_misc_elements_with_arg_map{$macro}))
+ {
+ my $arg = $args->[0];
+ $arg =~ s/^\s*//;
+ chomp($arg);
+ $result_text =
"<$xml_misc_elements_with_arg_map{$macro}>".main::substitute_line($arg,
"address@hidden")."</$xml_misc_elements_with_arg_map{$macro}>\n";
+ }
+ if ($macro eq 'setfilename')
+ {
+ my $arg = $args->[0];
+ $arg =~ s/^\s*//;
+ $arg =~ s/\s*$//;
+ $arg = main::substitute_line($arg, "address@hidden");
+ $arg =~ s/\.[^\.]*$//;
+ $result_text = "<${macro}>${arg}.xml</${macro}>\n";
+ }
+ return ($result_line, 1, $result_text, undef);
+}
+
+
+sub xml_anchor_label($$)
+{
+ my $id = shift;
+ my $anchor_text = shift;
+ return '<anchor name="'. &$protect_text($anchor_text) . '"></anchor>';
+}
+
+sub xml_index_entry_command($$$$$)
+{
+ my $command = shift;
+ my $index_name = shift;
+ my $label = shift;
+ my $entry_texi = shift;
+ my $entry_formatted = shift;
+
+ return $label if (defined($label) and $label ne '');
+ return
xml_index_entry_label('','','',$main::index_prefix_to_name{$index_name}, '',
'', $entry_formatted);
+}
+
+sub xml_index_entry_label($$$$$$$$)
+{
+ my $identifier = shift;
+ my $preformatted = shift;
+ my $formatted_entry = shift;
+ my $index_name = shift;
+ my $index_command = shift;
+ my $texi_entry = shift;
+ my $formatted_entry_reference = shift;
+ my $entry = shift;
+
+
+ return "<indexterm
index=\"${index_name}\">${formatted_entry_reference}</indexterm>";
+}
+
+sub xml_listoffloats($$$)
+{
+ my $style_texi = shift;
+ my $style = shift;
+ my $float_entries = shift;
+ # FIXME style, style_texi? Protected?
+ return "<listoffloats type=\"$style\"></listoffloats>";
+}
+
+sub xml_acronym_like($$$$$$)
+{
+ my $command = shift;
+ my $acronym_texi = shift;
+ my $acronym_text = shift;
+ my $with_explanation = shift;
+ my $explanation_lines = shift;
+ my $explanation_text = shift;
+ my $explanation_simply_formatted = shift;
+
+ $command = 'abbrev' if ($command eq 'abbr');
+ my $opening = "<${command}><${command}word>$acronym_text</${command}word>";
+ if ($with_explanation)
+ {
+ $opening .= "<${command}desc>$explanation_text</${command}desc>";
+ }
+ return $opening . "</${command}>";
+}
+
+sub xml_foot_line_and_ref($$$$$$$)
+{
+ my $number_in_doc = shift;
+ my $number_in_page = shift;
+ my $footnote_id = shift;
+ my $place_id = shift;
+ my $document_file = shift;
+ my $footnote_file = shift;
+ my $lines = shift;
+ my $state = shift;
+
+ my $result = '<footnote>';
+ foreach my $line (@$lines)
+ {
+ $result .= $line;
+ }
+ return ([], $result . '</footnote>');
+}
+
+sub xml_image($$$$$$$$$$$$$)
+{
+ my $file = shift;
+ my $base = shift;
+ my $preformatted = shift;
+ my $file_name = shift;
+ my $alt = shift;
+ my $width = shift;
+ my $height = shift;
+ my $raw_alt = shift;
+ my $extension = shift;
+ my $working_dir = shift;
+ my $file_path = shift;
+ my $in_paragraph = shift;
+ my $file_locations = shift;
+
+ $alt = '' if (!defined($alt));
+ # dirty hack to avoid " that can be here because of a @verb
+ $alt =~ s/"/"/g;
+
+ $width = '' if (!defined($width));
+ $height = '' if (!defined($height));
+
+ my $tag = 'inlineimage';
+ $tag = 'image' if ($preformatted or !$in_paragraph);
+
+ return "<$tag width=\"$width\" height=\"$height\" name=\"".
&$protect_text($base)."\"
extension=\"$extension\"><alttext>$alt</alttext></$tag>";
+}
+
+sub xml_sp($$)
+{
+ my $number = shift;
+ my $preformatted = shift;
+ return "<sp lines=\"$number\"></sp>\n";
+}
+
+sub xml_quotation($$$$)
+{
+ my $command = shift;
+ my $text = shift;
+ my $argument_text = shift;
+ my $argument_text_texi = shift;
+ return "<$command>\n" . $text . "</$command>\n";
+}
+
+sub xml_format_list_item_texi($$$$)
+{
+ my $format = shift;
+ my $line = shift;
+ my $prepended = shift;
+ my $command = shift;
+
+ my $result_line = undef;
+
+ if (defined($command) and $command ne '' and !exists
$special_list_commands{$format}->{$command} and $format ne 'itemize')
+ {
+ address@hidden
+ $line =~ s/^\s*//;
+ $line =~ s/\s*$//;
+ if (exists ($style_map{$command}))
+ {
+ $result_line = "address@hidden";
+ }
+ elsif (exists ($things_map{$command}))
+ {
+ $result_line = "address@hidden $line\n";
+ }
+ else
+ {
+ $result_line = "address@hidden $line\n";
+ }
+ }
+
+ return ($result_line, 0);
+}
+
+sub xml_list_item($$$$$$$$$)
+{
+ my $text = shift;
+ my $format = shift;
+ my $command = shift;
+ my $formatted_command = shift;
+ my $item_nr = shift;
+ my $enumerate_style = shift;
+ my $number = shift;
+ my $prepended = shift;
+ my $prepended_formatted = shift;
+
+ return '<item>' . $text . "</item>\n";
+}
+
+sub xml_init_variables()
+{
+ @xml_multitable_stack = ();
+ @xml_table_stack = ();
+}
+
+# row in multitable
+sub xml_row($$;$$)
+{
+ my $text = shift;
+ my $macro = shift;
+ my $columnfractions = shift;
+ my $prototype_row = shift;
+ my $prototype_lengths = shift;
+ my $column_number = shift;
+
+ my $result = '';
+ if ($macro eq 'headitem')
+ {
+ if ($xml_multitable_stack[-1] != 0)
+ {
+ $result .= "<thead>";
+ $result = "</tbody>" . $result if ($xml_multitable_stack[-1] ==
1);
+ $xml_multitable_stack[-1] = 0;
+ }
+ }
+ elsif ($xml_multitable_stack[-1] != 1)
+ {
+ $result .= "<tbody>";
+ $result = "</thead>" . $result if ($xml_multitable_stack[-1] == 0);
+ $xml_multitable_stack[-1] = 1;
+ }
+ $result .= "<row>$text</row>";
+
+ return $result;
+}
+
+# cell in multitable
+sub xml_cell($$;$$)
+{
+ my $text = shift;
+ my $row_macro = shift;
+ my $columnfractions = shift;
+ my $prototype_row = shift;
+ my $prototype_lengths = shift;
+ my $column_number = shift;
+
+ return "<entry>" . $text . '</entry>';
+}
+
+sub xml_table_list($$$$$$$$$)
+{
+ my $format_command = shift;
+ my $text = shift;
+ my $command = shift;
+ my $formatted_command = shift;
+# enumerate
+ my $item_nr = shift;
+ my $enumerate_style = shift;
+# itemize
+ my $prepended = shift;
+ my $prepended_formatted = shift;
+# multitable
+ my $columnfractions = shift;
+ my $prototype_row = shift;
+ my $prototype_lengths = shift;
+ my $number = shift;
+
+ my $result = "<$format_command>";
+ if ($format_command eq 'itemize')
+ {
+ my $itemfunction;
+ $prepended_formatted =~ s/^\s*// if (defined($prepended_formatted));
+ if (defined($formatted_command) and $formatted_command ne '')
+ {
+ $itemfunction = $formatted_command;
+ $itemfunction .= " $prepended_formatted" if
(defined($prepended_formatted) and $prepended_formatted ne '');
+ }
+ elsif (defined($prepended_formatted))
+ {
+ $itemfunction = $prepended_formatted;
+ }
+ $itemfunction = "•" if (!defined($itemfunction) or
+ $itemfunction eq '');
+ $result .= "<itemfunction>$itemfunction</itemfunction>";
+ }
+ elsif ($format_command eq 'enumerate')
+ {
+ $result = "<$format_command first=\"$enumerate_style\">";
+ }
+ elsif ($format_command eq 'multitable')
+ {
+ my $fractions;
+ my $multiply = 1;
+ if (defined($columnfractions) and (ref($columnfractions) eq 'ARRAY')
+ and scalar(@$columnfractions))
+ {
+ $fractions = [ @$columnfractions ];
+ $multiply = 100;
+ }
+ elsif (defined($prototype_lengths) and (ref($prototype_lengths) eq
'ARRAY')
+ and scalar(@$prototype_lengths))
+ {
+ $fractions = [ @$prototype_lengths ];
+ }
+
+ if (defined ($fractions))
+ {
+ foreach my $fraction (@$fractions)
+ {
+ $result .=
"<columnfraction>".($fraction*$multiply)."</columnfraction>\n";
+ }
+ }
+ $text .= "</tbody>" if ($xml_multitable_stack[-1] == 1);
+ $text .= "</thead>" if ($xml_multitable_stack[-1] == 0);
+ pop @xml_multitable_stack;
+ }
+ elsif ($format_command =~ /^(v|f)?table$/)
+ {
+ $result = '<table>';
+ $text .= '</tableitem>' if ($xml_table_stack[-1] == 1);
+ pop @xml_table_stack;
+ return $result . "$text</table>\n";
+ }
+ return $result . "$text</$format_command>\n";
+}
+
+sub xml_begin_format_texi($$$)
+{
+ my $command = shift;
+ my $line = shift;
+ my $state = shift;
+
+ push (@xml_multitable_stack, -1) if ($command eq 'multitable');
+ push (@xml_table_stack, 0) if ($command =~ /^(v|f)?table/);
+ return $line;
+}
+
+sub xml_def_line($$$$$$$$$$$$$$$)
+{
+ my $category_prepared = shift;
+ my $name = shift;
+ my $type = shift;
+ my $arguments = shift;
+ my $index_label = shift;
+ my $arguments_array = shift;
+ my $arguments_type_array = shift;
+ my $unformatted_arguments_array = shift;
+ my $command = shift;
+ my $class_name = shift;
+ my $category = shift;
+ my $class = shift;
+ my $style = shift;
+ my $original_command = shift;
+
+ my $result = "<definitionterm><indexterm index=\""
+ .$main::index_prefix_to_name{$style}."\">$class_name</indexterm>";
+
+ my %arguments = ( 'prepared_category' => $category_prepared,
+ 'category' => $category,
+ 'name' => $name,
+ 'type' => $type,
+ 'class' => $class
+ );
+ foreach my $type (keys(%arguments))
+ {
+ $arguments{$type} = '' if (!defined($arguments{$type}));
+ }
+
+ foreach my $mandatory_arg (@{$def_format_xml{$command}})
+ {
+ my $elem = $mandatory_arg->[0];
+ $result .= "<def$elem>$arguments{$mandatory_arg->[1]}</def$elem>";
+ }
+
+ my $params = '';
+ my @types = @$arguments_type_array;
+ foreach my $arg (@$arguments_array)
+ {
+ my $type = shift @types;
+ if (grep {$_ eq $type} ('param', 'paramtype', 'delimiter'))
+ {
+ $result .= "<def$type>$arg</def$type>";
+ }
+ }
+
+ $result .= "</definitionterm>\n";
+ return $result;
+}
+
+# FIXME
+# @deffn
+# @c comment
+# @end deffn
+# leads to the creation of a <definitionitem> with a comment within,
+# while there should be no definitionitem
+sub xml_def_item($$)
+{
+ my $text = shift;
+ my $only_inter_item_commands = shift;
+
+ if ($text =~ /\S/)
+ {
+ return '<definitionitem>' . $text . '</definitionitem>' unless
$only_inter_item_commands;
+ return $text;
+ }
+ return '';
+}
+
+sub xml_def($)
+{
+ my $text = shift;
+ return '<definition>'.$text.'</definition>';
+}
+
+sub xml_index_summary($$)
+{
+ my $alpha = shift;
+ my $nonalpha = shift;
+ return '';
+}
+
+sub xml_printindex($)
+{
+ my $name = shift;
+ return "<printindex>$name</printindex>\n";
+}
+
+sub xml_any_ref($$)
+{
+ my $type = shift;
+ my $args = shift;
+ my $result = '';
+ if ($type eq 'pxref')
+ {
+ $result = &$I('see ',{'duplicate'=>1});
+ }
+ elsif ($type eq 'xref' or $type eq 'inforef')
+ {
+ $result = &$I('See ',{'duplicate'=>1});
+ }
+ if ($type eq 'inforef')
+ {
+ $result .= "<inforef><inforefnodename>$args->[0]</inforefnodename>";
+ $result .= "<inforefrefname>$args->[1]</inforefrefname>" if
($args->[1] ne '');
+ $result .= "<inforefinfoname>$args->[2]</inforefinfoname></inforef>"
+ }
+ else
+ {
+ $result .= "<xref><xrefnodename>$args->[0]</xrefnodename>";
+ $result .= "<xrefinfoname>$args->[1]</xrefinfoname>" if ($args->[1] ne
'');
+ $result .= "<xrefprinteddesc>$args->[2]</xrefprinteddesc>" if
($args->[2] ne '');
+ $result .= "<xrefinfofile>$args->[3]</xrefinfofile>" if ($args->[3] ne
'');
+ $result .= "<xrefprintedname>$args->[4]</xrefprintedname>" if
($args->[4] ne '');
+ $result .= '</xref>';
+ }
+ return $result;
+}
+
+sub xml_external_ref($$$$$$)
+{
+ my $type = shift;
+ my $section = shift;
+ my $book = shift;
+ my $file_node = shift;
+ my $href = shift;
+ my $cross_ref = shift;
+ my $args_texi = shift;
+ my $formatted_args = shift;
+
+ return xml_any_ref ($type, $formatted_args);
+}
+
+sub xml_internal_ref($$$$$)
+{
+ my $type = shift;
+ my $href = shift;
+ my $short_name = shift;
+ my $name = shift;
+ my $is_section = shift;
+ my $args_texi = shift;
+ my $formatted_args = shift;
+
+ return xml_any_ref ($type, $formatted_args);
+}
+
+sub xml_table_item($$$$$$$)
+{
+ my $text = shift;
+ my $index_label = shift;
+ my $format = shift;
+ my $command = shift;
+# my $formatted_command = shift;
+ my $style_stack = shift;
+# my $text_formatted = shift;
+# my $text_formatted_leading_spaces = shift;
+# my $text_formatted_trailing_spaces = shift;
+ my $item_cmd = shift;
+ my $formatted_index_entry = shift;
+
+
+# $formatted_command = '' if (!defined($formatted_command));
+#
+# if (defined($text_formatted))
+# {
+# $text_item = $text_formatted_leading_spaces . $text_formatted
.$text_formatted_trailing_spaces;
+# }
+# else
+# {
+# $text_item = $text;
+# }
+
+ my $result = '';
+ if ($item_cmd eq 'item')
+ {
+ $result .= '</tableitem>' if ($xml_table_stack[-1] == 1);
+ $xml_table_stack[-1] = 1;
+ $result .= '<tableitem>';
+ }
+ $result .= '<tableterm>';
+ #print STDERR "$text | $format | $command | $formatted_command |
$text_formatted | $item_cmd \n";
+ my $indexterm = '';
+#print STDERR "FFFFFFFFFFFFFFFFf `$index_label' `$text'\n";
+ if ($format =~ /^(v|f)/)
+ {
+# my $index_prefix = $1;
+# $indexterm = $text;
+# $indexterm =~ s/^\s*//;
+# $result .= "<indexterm
index=\"$main::index_prefix_to_name{$index_prefix}\">$formatted_index_entry</indexterm>";
+ $result .= "$index_label";
+ }
+ $result .= $text ."</tableterm>\n";
+ return $result;
+}
+
+sub xml_table_line($)
+{
+ my $text = shift;
+ my $only_inter_item_commands = shift;
+ my $before_items = shift;
+
+ if ($text =~ /\S/)
+ {
+ return "<item>$text</item>" unless $only_inter_item_commands;
+ return $text;
+ }
+ else
+ {
+ return '';
+ }
+}
+
+sub xml_caption_shortcaption($)
+{
+ my $float = shift;
+ my $caption_lines;
+ my $shortcaption_lines;
+ if (defined($float->{'caption_texi'}))
+ {
+ @$caption_lines = @{$float->{'caption_texi'}};
+ }
+ if (defined($float->{'shortcaption_texi'}))
+ {
+ @$shortcaption_lines = @{$float->{'shortcaption_texi'}};
+ }
+ return ($caption_lines, $shortcaption_lines);
+}
+
+sub xml_caption_shortcaption_command($$$)
+{
+ my $command = shift;
+ my $text = shift;
+ my $texi_lines = shift;
+ my $float_element = shift;
+
+ if ($text =~ /\S/)
+ {
+ return "<$command>$text</$command>";
+ }
+ return '';
+}
+
+sub xml_float($$$$$)
+{
+ my $text = shift;
+ my $float = shift;
+ my $caption = shift;
+ my $shortcaption = shift;
+
+ my $label_texi = $float->{'texi'};
+ $label_texi = '' if (!defined($label_texi));
+ my $result = "<float name=\"$label_texi\">\n";
+ my $style = $float->{'style'};
+ $style = '' if (!defined($style));
+ $result .= "<floattype>$style</floattype>\n";
+ $result .= "<floatpos></floatpos>\n";
+ $result .= $text;
+ return $result."</float>\n";
+}
+
+sub xml_normal_text($$$$$$)
+{
+ my $text = shift;
+ my $in_raw_text = shift;
+ my $in_preformatted = shift;
+ my $in_code = shift;
+ my $in_simple = shift;
+#print STDERR "Bug: in_raw_text in_simple $text\n" if ($in_raw_text and
$in_simple);
+ my $style_stack = shift;
+ $text = &$protect_text($text) unless($in_raw_text);
+
+ if (! $in_code and !$in_preformatted and !$in_raw_text)
+ {
+ $text =~ s/---/\&mdash\;/g;
+ $text =~ s/--/\&ndash\;/g;
+ $text =~ s/``/\&ldquo\;/g;
+ $text =~ s/''/\&rdquo\;/g;
+ }
+ return $text;
+}
+
+sub xml_paragraph_style_command($$)
+{
+ my $format = shift;
+ my $text = shift;
+ return "<$format>$text</$format>" if ($format eq 'center');
+ return $text;
+}
+
+sub xml_raw($$)
+{
+ my $style = shift;
+ my $text = shift;
+
+ if ($style eq 'verbatim' or $style eq 'verbatiminclude')
+ {
+ return '<verbatim xml:space="preserve">' . &$protect_text($text) .
'</verbatim>';
+ }
+ return '' unless (grep {$style eq $_} @EXPAND);
+ if ($style eq 'xml')
+ {
+ chomp ($text);
+ return $text;
+ }
+ else
+ {
+ main::echo_warn ("Raw style $style not handled");
+ return &$protect_text($text);
+ }
+}
+
+sub xml_cartouche($$)
+{
+ my $text = shift;
+
+ return "<cartouche>$text</cartouche>";
+}
+
+sub xml_noop
+{
+ return '';
+}
+
+1;
Index: examples/docbook.init
===================================================================
RCS file: examples/docbook.init
diff -N examples/docbook.init
--- examples/docbook.init 17 May 2009 15:35:16 -0000 1.21
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,1561 +0,0 @@
-#+##############################################################################
-#
-# docbook.init: convert to docbook
-#
-# Copyright (C) 2008 Patrice Dumas <address@hidden>
-#
-# 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 2 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, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301 USA
-#
-#-##############################################################################
-
-use strict;
-
-$EXTENSION = "xml";
-$DOCTYPE = '<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
- <!ENTITY tex "TeX">
- <!ENTITY latex "LaTeX">
-]>';
-$USE_MENU_DIRECTIONS = 0;
-$USE_UP_FOR_ADJACENT_NODES = 0;
-$USE_NUMERIC_ENTITY = 0;
-$USE_SETFILENAME = 1;
address@hidden = ('docbook');
address@hidden = ('eps', 'gif', 'jpg', 'jpeg', 'pdf', 'png', 'svg', 'txt');
-$USE_ISO = 1;
-$INLINE_INSERTCOPYING = 1;
-
-$SHOW_MENU = 0;
-$SECTION_NAVIGATION = 0;
-
-push @command_handler_process, \&docbook_initialize_variables;
-
-$misc_command{'c'}->{'keep'} = 1;
-$misc_command{'comment'}->{'keep'} = 1;
-$misc_command{'settitle'}->{'keep'} = 1;
-
-delete $style_map{'sc'}->{'attribute'};
-$style_map{'code'}->{'attribute'} = 'literal';
-$style_map{'strong'}->{'attribute'} = 'emphasis role="bold"';
-$style_map{'kbd'}->{'attribute'} = 'userinput';
-$style_map{'w'}->{'end'} = '<!-- /@w -->';
-$style_map{'='}->{'function'} = \&docbook_macron;
-$style_map{'b'}->{'attribute'} = 'emphasis role="bold"';
-$style_map{'cite'}->{'attribute'} = 'citetitle';
-$style_map{'command'}->{'attribute'} = 'command';
-$style_map{'dfn'}->{'attribute'} = 'firstterm';
-$style_map{'emph'}->{'attribute'} = 'emphasis';
-$style_map{'env'}->{'attribute'} = 'envar';
-$style_map{'file'}->{'attribute'} = 'filename';
-$style_map{'i'}->{'attribute'} = 'wordasword';
-$style_map{'key'}->{'attribute'} = 'keycap';
-delete $style_map{'key'}->{'begin'};
-delete $style_map{'key'}->{'end'};
-$style_map{'option'}->{'attribute'} = 'option';
-$style_map{'t'}->{'attribute'} = 'literal';
-delete $style_map{'sansserif'}->{'attribute'};
-delete $style_map{'r'}->{'attribute'};
-$style_map{'indicateurl'}->{'attribute'} = 'wordasword';
-delete $style_map{'indicateurl'}->{'begin'};
-delete $style_map{'indicateurl'}->{'end'};
-$style_map{'var'}->{'attribute'} = 'replaceable';
-delete $style_map{'verb'}->{'attribute'};
-$style_map{'email'}->{'function'} = \&docbook_email;
-$style_map{'math'}->{'function'} = \&docbook_math;
-$style_map{'uref'}->{'function'} = \&docbook_uref;
-$style_map{'url'}->{'function'} = \&docbook_uref;
-$style_map{'titlefont'}->{'function'} = \&docbook_titlefont;
-$style_map{'samp'}->{'function'} = \&docbook_samp;
-delete $style_map{'samp'}->{'attribute'};
-#$style_map{'samp'}->{'attribute'} = 'literal';
-#$style_map{'samp'}->{'begin'} = '‘';
-#$style_map{'samp'}->{'end'} = '’';
-
-my $kept_footnote_function = $style_map{'footnote'}->{'function'};
-$style_map{'footnote'}->{'function'} = \&docbook_footnote;
-
-#use Data::Dumper;
-foreach my $command (keys(%style_map))
-{
- $style_map_pre{$command} = {};
-# $style_map_texi{$command} = {} if (!exists($style_map_texi{$command}));
-# $style_map_texi{$command}->{'args'} = $style_map{$command}->{'args'}
-# if (exists($style_map{$command}->{'args'}));
- #print STDERR "COMMAND $command";
-
- foreach my $key (keys(%{$style_map{$command}}))
- {
- $style_map_pre{$command}->{$key} = $style_map{$command}->{$key};
- }
-}
-# print STDERR "". Data::Dumper->Dump([\%style_map_texi]);
-
-$style_map_pre{'b'}->{'attribute'} = 'lineannotation';
-$style_map_pre{'i'}->{'attribute'} = 'lineannotation';
-$style_map_pre{'r'}->{'attribute'} = 'lineannotation';
-
-$colon_command_punctuation_characters{'.'} = '.';
-$colon_command_punctuation_characters{':'} = ':';
-$colon_command_punctuation_characters{'?'} = '?';
-$colon_command_punctuation_characters{'!'} = '!';
-
-delete $stop_paragraph_command{'titlefont'};
-
-#Â FIXME
-#$no_paragraph_commands{'anchor'} = 0;
-
-# FIXME
-delete $special_accents{'ringaccent'};
-$special_accents{'ogonek'} = 'aeiuAEIU';
-
-foreach my $style (keys(%style_map))
-{
- delete ($style_map{$style}->{'quote'});
-}
-
-my $docbook_in_footnote;
-sub docbook_footnote($$$$$)
-{
- $docbook_in_footnote = 1;
- my $result = &$kept_footnote_function(@_);
- $docbook_in_footnote = 0;
- return $result;
-}
-
-sub docbook_macron($$)
-{
- my $accent = shift;
- my $args = shift;
- return $args->[0] . "¯";
-}
-
-sub docbook_samp($$)
-{
- shift;
- my $args = shift;
- return "‘<literal>$args->[0]</literal>’";
-}
-
-sub docbook_email($$)
-{
- my $command = shift;
- my $args = shift;
- my $mail = shift @$args;
- my $text = shift @$args;
- $mail = main::normalise_space($mail);
- if (defined($text) and $text =~ /\S/)
- {
- return docbook_add_id('ulink').'
url="mailto:'.main::normalise_space($mail).'">'.$text.'</ulink>';
- }
- return docbook_add_id('email').">$mail</email>";
-}
-
-sub docbook_uref($$)
-{
- shift;
- my $args = shift;
- my $url = shift @$args;
- my $text = shift @$args;
- my $replacement = shift @$args;
- $url = main::normalise_space($url);
- $text = '' if (!defined($text));
- $replacement = '' if (!defined($replacement));
- $replacement = $text if ($replacement eq '');
- $replacement = $url if ($replacement eq '');
- $replacement = main::normalise_space($replacement);
-
- return docbook_add_id('ulink')." url=\"$url\">$replacement</ulink>";
-}
-
-# FIXME
-sub docbook_titlefont($$)
-{
- shift;
- my $args = shift;
- return "$args->[0]";
-}
-
-sub docbook_math($$)
-{
- shift;
- my $args = shift;
- my $text = shift @$args;
- $text =~ s/[{}]//g;
- return $text;
-}
-
-$simple_map{' '} = ' ';
-# or '' ?
-$simple_map{'*'} = "\n";
-$simple_map{"\t"} = ' ';
-$simple_map{"\n"} = ' ';
-
-%simple_map_pre = %simple_map;
-
-# FIXME right?
-$things_map{'l'} = '/l';
-$things_map{'L'} = '/L';
-$things_map{'TeX'} = '&tex;';
-$things_map{'LaTeX'} = '&latex;';
-$things_map{'enddots'} = '….';
-$things_map{'minus'} = '−';
-# FIXME ∗
-$iso_symbols{'point'} = '-!-';
-# FIXME ≡
-$iso_symbols{'equiv'} = '==';
-delete $iso_symbols{"'"};
-delete $iso_symbols{'`'};
-$things_map{'quotedblbase'} = '„';
-$things_map{'quotesinglbase'} = '‚';
-
-%pre_map = %things_map;
-
-#delete $inter_item_commands{'cindex'};
-
-#$no_paragraph_commands{'cindex'} = 0;
-$no_paragraph_commands{'float'} = 0;
-
-my %docbook_complex_format = (
- 'example' => 'screen',
- 'smallexample' => 'screen',
- 'display' => 'literallayout',
- 'smalldisplay' => 'literallayout',
- 'lisp' => 'programlisting',
- 'smalllisp' => 'programlisting',
- 'format' => 'abstract',
- 'smallformat' => 'screen'
-);
-
-$region_formats_kept{'copying'} = 1;
-
-$format_map{'copying'} = 'copying';
-
-delete $format_map{'enumerate'};
-foreach my $table ('table', 'ftable', 'vtable')
-{
- #$format_map{$table} = 'table';
- delete $format_map{$table};
-}
-
-delete $iso_symbols{'`'};
-$print_Top = \&docbook_print_Top;
-$print_Top_footer = \&docbook_print_Top_footer;
-$print_page_head = \&docbook_print_page_head;
-#$print_navigation = \&docbook_noop;
-$print_foot_navigation = \&docbook_noop;
-$toc_body = \&docbook_noop;
-$about_body = \&docbook_noop;
-$print_page_foot = \&docbook_print_page_foot;
-$end_section = \&docbook_end_section;
-$one_section = \&docbook_one_section;
-
-$heading = \&docbook_heading;
-#$heading_texi = \&docbook_heading_texi;
-$paragraph = \&docbook_paragraph;
-$preformatted = \&docbook_preformatted;
-$misc_element_label = \&docbook_noop;
-$element_label = \&docbook_element_label;
-$anchor_label = \&docbook_anchor_label;
-$index_entry_label = \&docbook_index_entry_label;
-$index_entry_command = \&docbook_index_entry_command;
-$listoffloats = \&docbook_noop;
-$acronym_like = \&docbook_acronym_like;
-$foot_line_and_ref = \&docbook_foot_line_and_ref;
-$image = \&docbook_image;
-$image_files = \&docbook_image_files;
-$sp = \&docbook_sp;
-$table_list = \&docbook_table_list;
-$row = \&docbook_row;
-$cell = \&docbook_cell;
-$list_item = \&docbook_list_item;
-$format_list_item_texi = \&docbook_format_list_item_texi;
-$unknown = \&docbook_misc_commands;
-$begin_format_texi = \&docbook_begin_format_texi;
-$def_line = \&docbook_def_line;
-$def = \&docbook_def;
-$def_item = \&docbook_def_item;
-$printindex = \&docbook_printindex;
-$index_summary = \&docbook_index_summary;
-$external_ref = \&docbook_external_ref;
-$internal_ref = \&docbook_internal_ref;
-$table_item = \&docbook_table_item;
-$table_line = \&docbook_table_line;
-$float = \&docbook_float;
-#$caption_shortcaption = \&docbook_caption_shortcaption;
-#$caption_shortcaption_command = \&docbook_caption_shortcaption_command;
-$normal_text = \&docbook_normal_text;
-#$paragraph_style_command = \&docbook_paragraph_style_command;
-$raw = \&docbook_raw;
-$cartouche = \&docbook_cartouche;
-
-$complex_format = \&docbook_complex_format;
-$format = \&docbook_format;
-$quotation = \&docbook_quotation;
-$quotation_prepend_text = \&docbook_quotation_prepend_text;
-$style = \&docbook_style;
-$insertcopying = \&docbook_insertcopying;
-
-sub docbook_print_page_head($)
-{
- my $fh = shift;
- my $language = get_conf('documentlanguage');
- print $fh <<EOT;
-<?xml version="1.0"?>
-$DOCTYPE
-<book id="$Texi2HTML::THISDOC{file_base_name}.$EXTENSION" lang="$language">
-EOT
-}
-
-sub docbook_print_page_foot($)
-{
- my $fh = shift;
- print $fh <<EOT;
-</book><!-- Keep this comment at the end of the file
-Local variables:
-mode: sgml
-sgml-indent-step:1
-sgml-indent-data:nil
-End:
--->
-EOT
-}
-
-my %docbook_sections = (
- 'top' => 'chapter',
- 'chapter' => 'chapter',
- 'unnumbered' => 'chapter',
- 'centerchap' => 'chapter',
- 'appendix' => 'appendix',
- 'majorheading' => 'other',
- 'chapheading' => 'other',
- 'heading' => 'sect1',
- 'subheading' => 'sect2',
- 'subsubheading' => 'sect3',
- 2 => 'sect1',
- 3 => 'sect2',
- 4 => 'sect3'
-);
-
-sub docbook_print_Top($$$)
-{
- my $fh = shift;
- my $has_top_heading = shift;
- my $element = shift;
- #print $fh "".docbook_heading($element);
- main::print_lines($fh, $Texi2HTML::THIS_SECTION);
-}
-
-sub docbook_element_tag($)
-{
- my $element = shift;
-#print STDERR "$element->{'texi'}, $element->{'tag_level'},
$element->{'level'}\n";
- return $docbook_sections{$element->{'tag_level'}} if
(exists($docbook_sections{$element->{'tag_level'}}));
- return $docbook_sections{$element->{'level'}} if
(exists($docbook_sections{$element->{'level'}}));
-}
-
-sub docbook_node_id($)
-{
- my $node_texi = shift;
- my $node = main::remove_texi($node_texi);
- $node =~ s/[\s\"]/-/g;
- return &$protect_text($node);
-}
-
-my $docbook_pending_node_id;
-my @docbook_multitable_stack = ();
-my @docbook_table_stack = ();
-sub docbook_initialize_variables()
-{
- $docbook_pending_node_id = undef;
- @docbook_multitable_stack = ();
- @docbook_table_stack = ();
-}
-
-sub docbook_add_id($)
-{
- my $element = shift;
- my $result = "<$element";
- if (defined($docbook_pending_node_id) and (!$docbook_in_footnote or
$element eq 'footnote'))
- {
- $result .= " id=\"$docbook_pending_node_id\"";
- $docbook_pending_node_id = undef;
- }
- return $result;
-}
-
-sub docbook_heading($$$$$)
-{
- my $element = shift;
- my $command = shift;
- my $texi_line = shift;
- my $line = shift;
- my $in_preformatted = shift;
-
- if (defined($command) and $command =~ /heading/)
- {
- my $text = '';
- if (defined($line))
- {
- $text = $line;
- # this isn't done in main program in that case...
- chomp ($text);
- $text =~ s/^\s*//;
- }
- return docbook_add_id('bridgehead')."
renderas=\"$docbook_sections{$command}\">$text</bridgehead>\n";
- }
-
-# my $node_element = $element;
-# if (defined($element->{'node_ref'}))
-# {
-# $node_element = $element->{'node_ref'};
-# }
-
- my $result = '';
-
-# FIXME verify xreflabel
- if (!$element->{'node'})
- {
- my $id_text = '';
- if ($element->{'with_node'})
- {
- my $id = $element->{'with_node'}->{'text_nonumber'};
- $id =~ s/ /-/g;
- $id_text = " id=\"$id\"";
- }
- my $title = $element->{'text_nonumber'};
- my $label = '';
- my $xreflabel = '';
- if ($element->{'number'})
- {
- my $label_nr = $element->{'number'};
- $label_nr =~ s/\.$//;
- $label = $label_nr;
- }
- else
- {
- my $xreftitle = $title;
- $xreflabel = " xreflabel=\"$xreftitle\"";
- }
- $result .= '<' . docbook_element_tag($element) . "
label=\"${label}\"${xreflabel}${id_text}>\n<title>$title</title>\n";
- }
- return $result;
-}
-
-sub docbook_element_label($$$$)
-{
- my $id = shift;
- my $element = shift;
- my $command = shift;
- my $line = shift;
-
- if ($element->{'node'} and !$element->{'with_section'})
- {
- $docbook_pending_node_id = docbook_node_id($element->{'texi'});
- }
- elsif ($command !~ /heading/)
- {
- $docbook_pending_node_id = undef;
- }
- return '';
-}
-
-sub docbook_paragraph($$$$$$$$$$$$)
-{
- my $text = shift;
- my $align = shift;
- my $indent = shift;
- my $paragraph_command = shift;
- my $paragraph_command_formatted = shift;
- my $paragraph_number = shift;
- my $format = shift;
- my $item_nr = shift;
- my $enumerate_style = shift;
- my $number = shift;
- my $command_stack_at_end = shift;
- my $command_stack_at_begin = shift;
-
- foreach my $style(t2h_collect_styles($command_stack_at_begin))
- {
-#print STDERR "PARA BEGIN STYLE $style\n";
- $text = t2h_begin_style($style, $text);
- }
- foreach my $style(t2h_collect_styles($command_stack_at_end))
- {
-#print STDERR "PARA END STYLE $style\n";
- $text = t2h_end_style($style, $text);
- }
- if (defined($paragraph_number) and defined($$paragraph_number))
- {
- $$paragraph_number++;
- }
-
- # no para in multitables, caption and shortcaptions.
- my $top_stack = '';
- $top_stack = $command_stack_at_begin->[-1] if (scalar
(@$command_stack_at_begin));
- return $text if ($top_stack eq 'multitable' or $top_stack eq
'shortcaption' or $top_stack eq 'caption' or $top_stack eq
'documentdescription');
-
- if ($text =~ /\S/)
- {
- #return docbook_add_id('para').">$text</para>";
- return "<para>$text</para>";
- }
- return $text;
-}
-
-my %def_format_docbook = (
- 'deffn' => [ ['function', 'name'] ],
- 'defvr' => [ ['varname', 'name'] ],
- 'deftypefn' => [ [ 'returnvalue', 'type' ], ['function', 'name'] ],
- 'deftypeop' => [ ['returnvalue', 'type'], ['methodname', 'name'] ],
- 'deftypevr' => [ ['returnvalue', 'type'], ['varname', 'name'] ],
- 'defcv' => [ ['classname', 'class'], ['property', 'name'] ],
- 'deftypecv' => [ ['returnvalue', 'type'], ['property', 'name'] ],
- 'defop' => [ ['classname', 'class'], ['methodname', 'name'] ],
- 'deftp' => [ ['structname', 'name'] ]
-);
-
-my %def_argument_types_docbook = (
- 'param' => 'replaceable',
- 'paramtype' => 'type',
- 'delimiter' => ''
-);
-
-sub docbook_def_line($$$$$$$$$$$$$$$)
-{
- my $category_prepared = shift;
- my $name = shift;
- my $type = shift;
- my $arguments = shift;
- my $index_label = shift;
- my $arguments_array = shift;
- my $arguments_type_array = shift;
- my $unformatted_arguments_array = shift;
- my $command = shift;
- my $class_name = shift;
- my $category = shift;
- my $class = shift;
- my $style = shift;
- my $original_command = shift;
-
- my %unformatted_arguments = ();
-
- my @unformatted_args = @$unformatted_arguments_array;
- foreach my $type (@$arguments_type_array)
- {
- my $unformatted_arg = shift @unformatted_args;
- $unformatted_arguments{$type} = $unformatted_arg;
- }
- # FIXME unformatted!
- my $result = "<synopsis
role=\"$unformatted_arguments{'category'}\"><indexterm role=\""
-
.$main::index_prefix_to_name{$style}."\"><primary>$class_name</primary></indexterm>";
-
- my %arguments = ( 'prepared_category' => $category_prepared,
- 'category' => $category,
- 'name' => $name,
- 'type' => $type,
- 'class' => $class
- );
- foreach my $type (keys(%arguments))
- {
- $arguments{$type} = '' if (!defined($arguments{$type}));
- }
-
- foreach my $mandatory_arg (@{$def_format_docbook{$command}})
- {
- my $elem = $mandatory_arg->[0];
- #if ($elem eq 'returnvalue' and
$unformatted_arguments{$mandatory_arg->[1]} =~ /address@hidden/)
- if ($elem eq 'returnvalue' and
$unformatted_arguments{$mandatory_arg->[1]} =~ /address@hidden/)
- {
- # FIXME unformatted
- my $arg_without_at_command =
$unformatted_arguments{$mandatory_arg->[1]};
- #$arg_without_at_command =~ s/address@hidden//;
- #$arg_without_at_command =~ s/\}\s*$//;
- while ($arg_without_at_command =~ /address@hidden([^\{\}]*)\}/)
- {
- $arg_without_at_command =~ s/address@hidden([^\{\}]*)\}/$1/;
- }
- $result .= "<$elem>$arg_without_at_command</$elem>";
- }
- else
- {
- $result .= "<$elem>$arguments{$mandatory_arg->[1]}</$elem>";
- }
- }
-
- my @types = @$arguments_type_array;
- @unformatted_args = @$unformatted_arguments_array;
- foreach my $arg (@$arguments_array)
- {
- my $type = shift @types;
- my $unformatted = shift @unformatted_args;
- if (exists ($def_argument_types_docbook{$type}))
- {
- if ($def_argument_types_docbook{$type} and
- ($type eq 'paramtype' or ($unformatted !~ /address@hidden/)))
- {
- $result .=
"<$def_argument_types_docbook{$type}>$arg</$def_argument_types_docbook{$type}>";
- }
- else
- {
- $result .= $arg;
- }
- }
- }
-
- $result .= "</synopsis>\n";
- return $result;
-}
-
-# FIXME
-# @deffn
-# @c comment
-# @end deffn
-# leads to the creation of a <definitionitem> with a comment within,
-# while there should be no definitionitem
-sub docbook_def_item($)
-{
- my $text = shift;
- my $only_inter_item_commands = shift;
-
- if ($text =~ /\S/)
- {
- return '<blockquote>' . $text . '</blockquote>' unless
$only_inter_item_commands;
- return $text;
- }
- return '';
-}
-
-sub docbook_def($)
-{
- my $text = shift;
- return docbook_add_id('informalfigure').'>'.$text.'</informalfigure>';
-}
-
-sub docbook_preformatted($$$$$$$$$$$$)
-{
- my $text = shift;
- my $pre_style = shift;
- my $class = shift;
- my $leading_command = shift;
- my $leading_command_formatted = shift;
- my $preformatted_number = shift;
- my $format = shift;
- my $item_nr = shift;
- my $enumerate_style = shift;
- my $number = shift;
- my $command_stack_at_end = shift;
- my $command_stack_at_begin = shift;
-
- return $text;
-}
-
-sub docbook_misc_commands($$$$$)
-{
- my $macro = shift;
- my $line = shift;
- my $pass = shift;
- my $stack = shift;
- my $state = shift;
-#print STDERR "$macro $pass $line";
- return ($line, 0, undef, undef) unless ($pass == 2);
- return ($line, 0, undef, undef) unless defined($misc_command{$macro});
-
- my ($result_line, $text, $args) = &$preserve_misc_command ($line, $macro);
-#print STDERR "$macro $pass $line";
-#print STDERR "ARGS @$args\n" if defined ($args);
- my $result_text = undef;
- if ($macro eq 'c' or $macro eq 'comment' and scalar(@$args))
- {
- my $comment_line = $args->[0];
- chomp ($comment_line);
- # makeinfo remove all the leading spaces
- $comment_line =~ s/^\s//;
- $result_text = &$comment ($comment_line);
- }
- elsif ($macro eq 'settitle')
- {
- # FIXME to be formatted?
- my $arg = $args->[0];
- $arg =~ s/^\s*//;
- chomp($arg);
- $result_text = "<title>$arg</title>\n";
- }
- else
- {
- return ($line, 0, undef, undef);
- }
- return ($result_line, 1, $result_text, undef);
-}
-
-sub docbook_foot_line_and_ref($$$$$$$)
-{
- my $number_in_doc = shift;
- my $number_in_page = shift;
- my $footnote_id = shift;
- my $place_id = shift;
- my $document_file = shift;
- my $footnote_file = shift;
- my $lines = shift;
- my $state = shift;
-
- my $result = docbook_add_id('footnote').'>';
- foreach my $line (@$lines)
- {
- $result .= $line;
- }
- return ([], $result . '</footnote>');
-}
-
-sub docbook_any_ref($$$)
-{
- my $type = shift;
- my $args = shift;
- my $unformatted_args = shift;
-
- if ($type eq 'inforef')
- {
- my $node_file = "($args->[2])$args->[0]";
- if ($args->[1] ne '')
- {
- return "*note $args->[1]: $node_file";
- }
- else
- {
- return "*note ${node_file}::";
- }
- }
- else
- {
- if (($args->[3] ne '') or ($args->[4] ne ''))
- {
- return '' if ($args->[4] eq '');
- my $section_name = $args->[2];
- $section_name = $args->[0] if ($section_name eq '');
- if ($type eq 'ref')
- {
- return &$I('section address@hidden'@asis{}\' in
@cite{%{book}}', { 'section_name' => $section_name, 'book' => $args->[4]
},{'duplicate'=>1});
- }
- elsif ($type eq 'xref')
- {
- return &$I('See section address@hidden'@asis{}\' in
@cite{%{book}}', { 'section_name' => $section_name, 'book' => $args->[4]
},{'duplicate'=>1});
- }
- elsif ($type eq 'pxref')
- {
- return &$I('see section address@hidden'@asis{}\' in
@cite{%{book}}', { 'section_name' => $section_name, 'book' => $args->[4]
},{'duplicate'=>1});
- }
- }
- my $link = docbook_node_id($unformatted_args->[0]);
- my $title = $args->[2];
- $title = $args->[1] if ($title eq '');
- if ($title eq '')
- {
- if ($type eq 'ref')
- {
- return &$I('%{ref}', {'ref' => docbook_add_id('xref')."
linkend=\"$link\"></xref>"});
- }
- elsif ($type eq 'pxref')
- {
- return &$I('see %{ref}', {'ref' => docbook_add_id('xref')."
linkend=\"$link\"></xref>"});
- }
- elsif ($type eq 'xref')
- {
- return &$I('See %{ref}', {'ref' => docbook_add_id('xref')."
linkend=\"$link\"></xref>"});
- }
- }
- else
- {
- if ($type eq 'ref')
- {
- return &$I('%{title_ref}', {'title_ref' =>
docbook_add_id('link')." linkend=\"$link\">$title</link>"});
- }
- elsif ($type eq 'pxref')
- {
- return &$I('see %{title_ref}', {'title_ref' =>
docbook_add_id('link')." linkend=\"$link\">$title</link>"},{'duplicate'=>1});
- }
- elsif ($type eq 'xref')
- {
- return &$I('See %{title_ref}', {'title_ref' =>
docbook_add_id('link')." linkend=\"$link\">$title</link>"},{'duplicate'=>1});
- }
- }
- }
-}
-
-sub docbook_external_ref($$$$$$)
-{
- my $type = shift;
- my $section = shift;
- my $book = shift;
- my $file_node = shift;
- my $href = shift;
- my $cross_ref = shift;
- my $args_texi = shift;
- my $formatted_args = shift;
-
- return docbook_any_ref ($type, $formatted_args, $args_texi);
-}
-
-sub docbook_internal_ref($$$$$)
-{
- my $type = shift;
- my $href = shift;
- my $short_name = shift;
- my $name = shift;
- my $is_section = shift;
- my $args_texi = shift;
- my $formatted_args = shift;
-
- return docbook_any_ref ($type, $formatted_args, $args_texi );
-}
-
-sub docbook_index_entry_command($$$$$)
-{
- my $command = shift;
- my $index_name = shift;
- my $label = shift;
- my $entry_texi = shift;
- my $entry_formatted = shift;
-
- return $label if (defined($label) and $label ne '');
- return
docbook_index_entry_label('','','',$main::index_prefix_to_name{$index_name},
'', '', $entry_formatted);
-}
-
-sub docbook_index_entry_label($$$$$)
-{
- my $identifier = shift;
- my $preformatted = shift;
- my $entry = shift;
- my $index_name = shift;
- my $index_command = shift;
- my $texi_entry = shift;
- my $formatted_entry = shift;
-
- return "<indexterm
role=\"${index_name}\"><primary>${formatted_entry}</primary></indexterm>";
-}
-
-sub docbook_footing($)
-{
- my $element = shift;
-
- my $result = '';
-
- return '' if ($element->{'node'});
- return '</'.docbook_element_tag($element).">\n" if ($element->{'level'} ==
0);
- return '' if ($element->{'child'});
- $result .= '</'.docbook_element_tag($element).">\n";
-
- return $result if ($element->{'sectionnext'} or $element->{'level'} == 1);
- my $current = $element;
- while ($current->{'level'} != 1 and $current->{'sectionup'} and
(!$current->{'sectionup'}->{'sectionnext'} or
$current->{'sectionup'}->{'level'} == 1))
- {
- $current = $current->{'sectionup'};
- $result .= '</'.docbook_element_tag($current).">\n";
- }
- return $result;
-}
-
-sub docbook_end_section($$$)
-{
- my $fh = shift;
- my $end_foot_navigation = shift;
- my $element = shift;
- print $fh "". docbook_footing($element);
-}
-
-sub docbook_print_Top_footer($$)
-{
- my $fh = shift;
- my $end_page = shift;
- my $element = shift;
-
- print $fh "". docbook_footing($element);
-}
-
-sub docbook_one_section($$)
-{
- my $fh = shift;
- my $element = shift;
- main::print_lines($fh);
- print $fh "". docbook_footing($element);
- &$print_foot_navigation($fh);
- &$print_page_foot($fh);
-}
-
-sub docbook_insertcopying($)
-{
- my $text = shift;
- my $comment = shift;
- my $simple_text = shift;
-
- return $text;
-}
-
-sub docbook_acronym_like($$$$$$)
-{
- my $command = shift;
- my $acronym_texi = shift;
- my $acronym_text = shift;
- my $with_explanation = shift;
- my $explanation_lines = shift;
- my $explanation_text = shift;
- my $explanation_simply_formatted = shift;
-
- $command = 'abbrev' if ($command eq 'abbr');
- my $result = docbook_add_id($command).">$acronym_text</${command}>";
- if ($with_explanation)
- {
- $result .= " ($explanation_text)";
- }
- return $result;
-}
-
-
-sub docbook_image_files($$$$)
-{
- my $base = shift;
- my $extension = shift;
- my $texi_base = shift;
- my $texi_extension = shift;
- my @files = ();
- return @files if (!defined($base) or ($base eq ''));
-# FIXME should look at extension argument? makeinfo doesn't
-# push @files,"$base.$extension" if (defined($extension) and ($extension ne
''));
- foreach my $ext (@IMAGE_EXTENSIONS)
- {
- push @files, ["$base.$ext", "$texi_base.$ext"];
- }
- return @files;
-}
-
-
-sub docbook_image($$$$$$$$$$$$$$$$;$)
-{
- my $file = shift;
- my $base = shift;
- my $preformatted = shift;
- my $file_name = shift;
- my $alt = shift;
- my $width = shift;
- my $height = shift;
- my $raw_alt = shift;
- my $extension = shift;
- my $working_dir = shift;
- my $file_path = shift;
- my $in_paragraph = shift;
- my $file_locations = shift;
- my $base_simple_format = shift;
- my $extension_simple_format = shift;
- my $file_name_simple_format = shift;
- my $line_nr = shift;
-
-# if (!defined($file_path) or $file_path eq '' or $file_path =~ /\.txt$/)
-# {
-# if (defined($extension) and $extension ne '')
-# {
-# $file = "$base.$extension";
-# }
-# else
-# {
-# $file = "$base.jpg";
-# $extension = 'jpg';
-# }
-# main::echo_warn ("no image file for $base, (using $file)");
-# }
- my $txt_path;
- my @files = ();
- my @extensions = @IMAGE_EXTENSIONS;
- foreach my $file_location (@$file_locations)
- {
- my ($file_located, $path, $file_simple_format) = @$file_location;
- my $extension = shift @extensions;
- if (defined($path))
- {
- if ($extension eq 'txt' and !defined($txt_path))
- {
- $txt_path = $path;
- }
- else
- {
- push @files, [$file_located, uc($extension),
$file_simple_format];
- }
- }
- }
- push @files, ["$base.jpg", 'JPG', "$base_simple_format.jpg" ] unless
(@files);
-
- my $begin = docbook_add_id('inlinemediaobject').'>';
- my $end = '</inlinemediaobject>';
- if ($preformatted or !$in_paragraph)
- {
- $begin = docbook_add_id('informalfigure').'><mediaobject>';
- $end = '</mediaobject></informalfigure>';
- }
- my $result = $begin;
- foreach my $file_spec (@files)
- {
- $result .= "<imageobject><imagedata fileref=\"$file_spec->[2]\"
format=\"$file_spec->[1]\"></imagedata></imageobject>";
- }
- if (defined($txt_path))
- {
- if (open(TXT, "<$txt_path"))
- {
- if (defined($Texi2HTML::THISDOC{'IN_ENCODING'}) and $USE_UNICODE)
- {
- binmode(TXT, ":encoding($Texi2HTML::THISDOC{'IN_ENCODING'})");
- }
- $result.="<textobject><literallayout>";
- while (my $img_txt = <TXT>)
- {
- $result .= $img_txt;
- }
- $result .= '</literallayout></textobject>';
- close(TXT);
- }
- else
- {
- main::echo_warn ("address@hidden file `$txt_path' unreadable: $!",
$line_nr);
- }
- }
- else
- {
- main::echo_warn ("Cannot find address@hidden file `$base.txt'",
$line_nr);
- }
-
- return "$result$end";
-}
-
-sub docbook_format_list_item_texi($$$$)
-{
- my $format = shift;
- my $line = shift;
- my $prepended = shift;
- my $command = shift;
-
- my $result_line = undef;
-
- if (defined($command) and $command ne '' and !exists
$special_list_commands{$format}->{$command} and $format ne 'itemize')
- {
- address@hidden
- $line =~ s/^\s*//;
- $line =~ s/\s*$//;
- if (exists ($style_map{$command}))
- {
- $result_line = "address@hidden";
- }
- elsif (exists ($things_map{$command}))
- {
- $result_line = "address@hidden $line\n";
- }
- else
- {
- $result_line = "address@hidden $line\n";
- }
- }
-
- return ($result_line, 0);
-}
-
-
-# row in multitable
-sub docbook_row($$;$$)
-{
- my $text = shift;
- my $macro = shift;
- my $columnfractions = shift;
- my $prototype_row = shift;
- my $prototype_lengths = shift;
- my $column_number = shift;
-
- my $result = '';
- if ($macro eq 'headitem')
- {
- if ($docbook_multitable_stack[-1] != 0)
- {
- $result .= "<thead>";
- $result = "</tbody>" . $result if ($docbook_multitable_stack[-1]
== 1);
- $docbook_multitable_stack[-1] = 0;
- }
- }
- elsif ($docbook_multitable_stack[-1] != 1)
- {
- $result .= "<tbody>";
- $result = "</thead>" . $result if ($docbook_multitable_stack[-1] ==
0);
- $docbook_multitable_stack[-1] = 1;
- }
- $result .= "<row>$text</row>";
-
- return $result;
-}
-
-# cell in multitable
-sub docbook_cell($$;$$)
-{
- my $text = shift;
- my $row_macro = shift;
- my $columnfractions = shift;
- my $prototype_row = shift;
- my $prototype_lengths = shift;
- my $column_number = shift;
-
- return "<entry>" . $text . '</entry>';
-}
-
-# if varlistentry_state is > 0 it means that a varlistentry is opened.
-# if varlistentry_state is == 2 it means that we are in a succession
-# of term
-# if varlistentry_state is == 1 it means that we are in the line
-# Having a listitem in a varlistentry is a must, so an empty
-# listitem is added if a varlistentry is closed and varlistentry_state == 2
-#
-# varlistentry acceps only term and listitem, so inter_item_commands
-# are put in the next term, or, if at the end of the table in a last
-# listitem
-sub docbook_table_item($$$$$$)
-{
- my $text = shift;
- my $index_label = shift;
- my $format = shift;
- my $command = shift;
-# my $formatted_command = shift;
- my $style_stack = shift;
-# my $text_formatted = shift;
-# my $text_formatted_leading_spaces = shift;
-# my $text_formatted_trailing_spaces = shift;
- my $item_cmd = shift;
-
-# $formatted_command = '' if (!defined($formatted_command));
-
-# if (defined($text_formatted))
-# {
-# $text_item = $text_formatted_leading_spaces . $text_formatted
.$text_formatted_trailing_spaces;
-# }
-# else
-# {
-# $text_item = $text;
-# }
-
- my $result = '';
- my $prepended = '';
- if (defined($docbook_table_stack[-1]->{'inter_item'}))
- {
- #$formatted_command = $docbook_table_stack[-1]->{'inter_item'} .
$formatted_command;
- $prepended = $docbook_table_stack[-1]->{'inter_item'};
- delete $docbook_table_stack[-1]->{'inter_item'};
- }
- if ($item_cmd eq 'item')
- {
- if ($docbook_table_stack[-1]->{'varlistentry_state'} == 2)
- {
- $result .= "<listitem><para><!-- empty table line
--></para></listitem>";
- }
- if ($docbook_table_stack[-1]->{'varlistentry_state'} >= 1)
- {
- $result .= '</varlistentry>';
- }
- $docbook_table_stack[-1]->{'varlistentry_state'} = 2;
- $result .= '<varlistentry>';
- }
- $result .= '<term>';
- $result .= $prepended . $text ."</term>\n";
- return $result;
-}
-
-sub docbook_table_line($$$)
-{
- my $text = shift;
- my $only_inter_item_commands = shift;
- my $before_items = shift;
-
- $only_inter_item_commands = '' if (!defined($only_inter_item_commands));
-
-#print STDERR
-
- if ($text =~ /\S/)
- {
- if ($before_items)
- {
- return $text;
- }
-
- if ($only_inter_item_commands)
- {
- $docbook_table_stack[-1]->{'inter_item'} = $text;
- return '';
- }
- else
- {
- $docbook_table_stack[-1]->{'varlistentry_state'} = 1;
- return "<listitem>$text</listitem>";
- }
- #return $text;
- }
- else
- {
- return '';
- }
-}
-
-sub docbook_list_item($$$$$$$$$)
-{
- my $text = shift;
- my $format = shift;
- my $command = shift;
- my $formatted_command = shift;
- my $item_nr = shift;
- my $enumerate_style = shift;
- my $number = shift;
- my $prepended = shift;
- my $prepended_formatted = shift;
- my $only_inter_item_commands = shift;
- my $before_items = shift;
-
- $only_inter_item_commands = '' if (!defined($only_inter_item_commands));
-
-#my $prep_t = 'UNDEF'; $prep_t = $prepended if (defined($prepended));
-#$item_nr = 0 if (!defined($item_nr));
-#print STDERR " $item_nr --> $prep_t|${text}!!!!!\n";
- #return $text if ($only_inter_item_commands and $before_items);
- return $text if ($before_items);
- return '<listitem>' . $text . "</listitem>\n";
-}
-
-sub docbook_table_list($$$$$$$$$)
-{
- my $format_command = shift;
- my $text = shift;
- my $command = shift;
- my $formatted_command = shift;
-# enumerate
- my $item_nr = shift;
- my $enumerate_style = shift;
-# itemize
- my $prepended = shift;
- my $prepended_formatted = shift;
-# multitable
- my $columnfractions = shift;
- my $prototype_row = shift;
- my $prototype_lengths = shift;
- my $number = shift;
-
- my $result = "<$format_command>";
- if ($format_command eq 'itemize')
- {
- my $itemfunction;
- #$prepended_formatted =~ s/^\s*// if (defined($prepended_formatted));
- $prepended =~ s/^\s*// if (defined($prepended));
- #if (defined($formatted_command) and $formatted_command ne '')
- if (defined($command) and $command ne '')
- {
- #$itemfunction = $formatted_command;
- $itemfunction = $command;
- #$itemfunction .= " $prepended_formatted" if
(defined($prepended_formatted) and $prepended_formatted ne '');
- $itemfunction .= " $prepended" if (defined($prepended) and
$prepended ne '');
- }
- #elsif (defined($prepended_formatted))
- elsif (defined($prepended))
- {
- #$itemfunction = $prepended_formatted;
- $itemfunction = $prepended;
- }
- my $mark = '';
- $mark = " mark=\"$itemfunction\"" if (defined($itemfunction) and
$itemfunction ne '');
- return docbook_add_id('itemizedlist')."${mark}>$text</itemizedlist>";
- }
- elsif ($format_command eq 'enumerate')
- {
- my $numeration='arabic';
- if (defined($enumerate_style) and $enumerate_style ne '')
- {
- if ($enumerate_style =~ /^[A-Z]/)
- {
- $numeration = 'upperalpha';
- }
- elsif ($enumerate_style =~ /^[a-z]/)
- {
- $numeration = 'loweralpha';
- }
- }
- return docbook_add_id('orderedlist') ."
numeration=\"$numeration\">$text</orderedlist>";
- }
- elsif ($format_command eq 'multitable')
- {
- my $result = docbook_add_id('informaltable').'><tgroup
cols="'.$number.'">';
- my $fractions;
- my $multiply = 1;
- if (defined($columnfractions) and (ref($columnfractions) eq 'ARRAY')
- and scalar(@$columnfractions))
- {
- $fractions = [ @$columnfractions ];
- $multiply = 100;
- }
- elsif (defined($prototype_lengths) and (ref($prototype_lengths) eq
'ARRAY')
- and scalar(@$prototype_lengths))
- {
- $fractions = [ @$prototype_lengths ];
- }
-
- if (defined ($fractions))
- {
- foreach my $fraction (@$fractions)
- {
- $result .= '<colspec
colwidth="'.($fraction*$multiply).'*"></colspec>';
- }
- }
- $text .= "</tbody>" if ($docbook_multitable_stack[-1] == 1);
- $text .= "</thead>" if ($docbook_multitable_stack[-1] == 0);
- pop @docbook_multitable_stack;
- return $result . "$text</tgroup></informaltable>";
- }
- elsif ($format_command =~ /^(v|f)?table$/)
- {
- $result = docbook_add_id('variablelist').'>';
- if (defined($docbook_table_stack[-1]->{'inter_item'}))
- { # there is a para in case there is only a comment, to avoid
- # an empty listitem
- $text .=
"<listitem><para>$docbook_table_stack[-1]->{'inter_item'}</para></listitem>";
- }
- elsif ($docbook_table_stack[-1]->{'varlistentry_state'} == 2)
- {
- $text .= "<listitem><para><!-- empty table line
--></para></listitem>";
- }
- $text .= '</varlistentry>' if
($docbook_table_stack[-1]->{'varlistentry_state'} >= 1);
- pop @docbook_table_stack;
- return $result . "$text</variablelist>\n";
- }
-}
-
-sub docbook_begin_format_texi($$$)
-{
- my $command = shift;
- my $line = shift;
- my $state = shift;
-
- push (@docbook_multitable_stack, -1) if ($command eq 'multitable');
- push (@docbook_table_stack, {'varlistentry_state' => 0}) if ($command =~
/^(v|f)?table/);
- return $line;
-}
-
-# FIXME
-sub docbook_sp($$)
-{
- my $number = shift;
- my $preformatted = shift;
- return "";
-}
-
-sub docbook_index_summary($$)
-{
- my $alpha = shift;
- my $nonalpha = shift;
- return '';
-}
-
-sub docbook_printindex($$)
-{
- my $name = shift;
- return docbook_add_id('index')."></index>\n";
-}
-
-sub docbook_complex_format($$)
-{
- my $name = shift;
- my $text = shift;
- return '' if ($text eq '');
- my $result = docbook_add_id($docbook_complex_format{$name}).'>'
.$text."</$docbook_complex_format{$name}>";
- return $result;
-}
-
-sub docbook_format($$)
-{
- my $name = shift;
- my $element = shift;
- my $text = shift;
- return '' if ($text eq '');
- return $text if ($format_map{$name} eq '');
- if ($name eq 'copying')
- {
- return "<bookinfo>\n<legalnotice>\n$text</legalnotice>\n</bookinfo>\n";
- }
- return docbook_add_id($format_map{$name}).'>'
.$text."</$format_map{$name}>";
-}
-
-my @docbook_special_quotation = ('note', 'caution', 'important', 'tip',
'warning');
-
-sub docbook_quotation_prepend_text($$)
-{
- my $command = shift;
- my $argument_text = shift;
-
- return undef if (!defined($argument_text) or $argument_text =~ /^$/);
-
- chomp($argument_text);
- my $text = $argument_text;
- $text =~ s/^\s*//;
- $text =~ s/\s*$//;
-
- return undef if (grep {lc($text) eq $_} @docbook_special_quotation);
- return &$I('@b{%{quotation_arg}:} ', {'quotation_arg' => $argument_text},
{'keep_texi' => 1});
-}
-
-
-sub docbook_quotation($$$$)
-{
- my $command = shift;
- my $text = shift;
- my $argument_text = shift;
- my $argument_text_texi = shift;
-
- $argument_text_texi = '' if (!defined($argument_text_texi));
- $argument_text_texi =~ s/^\s*//;
- $argument_text_texi =~ s/\s*$//;
- my $docbook_command = 'blockquote';
- if (grep {lc($argument_text_texi) eq $_} @docbook_special_quotation)
- {
- $docbook_command = lc($argument_text_texi);
- }
- return docbook_add_id($docbook_command).'>' . $text .
"</$docbook_command>\n";
-}
-
-sub docbook_style($$$$$$$$$)
-{
- my $style = shift;
- my $command = shift;
- my $text = shift;
- my $args = shift;
- my $no_close =shift;
- my $no_open = shift;
- my $line_nr = shift;
- my $state = shift;
- my $command_stack = shift;
-
- my $result = $text;
- if (exists($style->{'function'}))
- {
- my $function = $style->{'function'};
- $result = &$function($command, $args, $command_stack, $state,
$line_nr);
- }
- elsif (exists($style->{'attribute'}))
- {
- my $attribute = $style->{'attribute'};
- my $attribute_text = '';
- if ($attribute =~ /^(\w+)(\s+.*)/)
- {
- $attribute = $1;
- $attribute_text = $2;
- }
-
- $result =
docbook_add_id($attribute)."$attribute_text>$text</$attribute>";
- }
- if (exists($style->{'begin'}))
- {
- $result = $style->{'begin'} . $result;
- }
- if (exists($style->{'end'}))
- {
- $result .= $style->{'end'};
- }
- return $result;
-}
-
-sub docbook_raw($$$)
-{
- my $style = shift;
- my $text = shift;
- my $line_nr = shift;
-
- if ($style eq 'verbatim' or $style eq 'verbatiminclude')
- {
- return docbook_add_id('screen').'>' . &$protect_text($text) .
'</screen>';
- }
- return '' unless (grep {$style eq $_} @EXPAND);
- if ($style eq 'docbook')
- {
- chomp ($text);
- return $text;
- }
- else
- {
- main::echo_warn ("Raw style $style not handled", $line_nr);
- return &$protect_text($text);
- }
-}
-
-sub docbook_cartouche($$)
-{
- my $text = shift;
-
- return "$text";
-}
-
-sub docbook_anchor_label($$)
-{
- my $id = shift;
- my $anchor_text = shift;
- return '<anchor id="'. &$protect_text($anchor_text) . '"></anchor>';
-}
-
-sub docbook_float($$$$$)
-{
- my $text = shift;
- my $float = shift;
- my $caption = shift;
- my $shortcaption = shift;
-
- my $label_texi = $float->{'texi'};
- return $text if (!defined($label_texi) or $label_texi eq '');
-
- return docbook_anchor_label('',$label_texi) . $text;
-}
-
-sub docbook_normal_text($$$$$$)
-{
- my $text = shift;
- my $in_raw_text = shift; # remove_texi
- my $in_preformatted = shift;
- my $in_code = shift;
- my $in_simple = shift;
-#print STDERR "Bug: in_raw_text in_simple $text\n" if ($in_raw_text and
$in_simple);
- my $style_stack = shift;
- #$text = uc($text) if (in_cmd($style_stack, 'sc'));
- $text = &$protect_text($text) unless($in_raw_text);
- if (! $in_code and !$in_preformatted)
- {
- if (!$in_raw_text)
- {
- $text =~ s/---/\&mdash\;/g;
- $text =~ s/--/\&ndash\;/g;
- $text =~ s/``/\&ldquo\;/g;
- $text =~ s/''/\&rdquo\;/g;
- }
- else
- {
- #FIXME really do that ? It is done by makeinfo in hhml
- $text =~ s/``/"/g;
- $text =~ s/''/"/g;
- # temporary reuse '' to store --- !....
- # FIXME won't '---' be handled wrongly?
- # FIXME really do that in raw text?
- $text =~ s/---/''/g;
- $text =~ s/--/-/g;
- $text =~ s/''/--/g;
- }
- }
- return $text;
-}
-
-sub docbook_noop
-{
- return '';
-}
-
-1;
Index: examples/info.init
===================================================================
RCS file: examples/info.init
diff -N examples/info.init
--- examples/info.init 20 May 2009 23:22:22 -0000 1.42
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,3138 +0,0 @@
-#+##############################################################################
-#
-# info.init: convert to info
-#
-# Copyright (C) 2008, 2009 Patrice Dumas <address@hidden>
-#
-# 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 2 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, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301 USA
-#
-#-##############################################################################
-
-use Data::Dumper;
-
-use strict;
-
-$Data::Dumper::Maxdepth = 12;
-
-
-$USE_NODES = 1;
-$USE_SECTIONS = 0;
address@hidden = ('info', 'direntry');
-$EXTENSION = 'info';
-$SHOW_MENU = 1;
-$USE_SETFILENAME = 1;
-$IGNORE_BEFORE_SETFILENAME = 1;
-$NODE_NAME_IN_MENU = 1;
-$SPLIT_INDEX = 0;
-$FOOTNOTESTYLE = 'end';
-$INLINE_CONTENTS = 1;
-$INLINE_INSERTCOPYING = 1;
-$SIMPLE_MENU = 1;
-$MENU_SYMBOL = '*';
-$USE_MENU_DIRECTIONS = 0;
-$USE_UP_FOR_ADJACENT_NODES = 0;
-$USE_ISO = 0;
-$ENABLE_ENCODING_USE_ENTITY = 0;
-$ENABLE_ENCODING = 1;
address@hidden = ('png', 'jpg', 'txt');
-$CAPTION_STYLE = 'asis';
-$DEFAULT_ENCODING = 'ascii';
-
-
-$no_paragraph_commands{'anchor'} = 1;
-
-%simple_map = %ascii_simple_map;
-%simple_map_pre = %simple_map;
-%simple_map_texi = %simple_map;
-
-%things_map = %ascii_things_map;
-%pre_map = %things_map;
-
-$misc_command{'exdent'}->{'keep'} = 1;
-$misc_command{'noindent'}->{'keep'} = 1;
-$misc_command{'indent'}->{'keep'} = 1;
-
-%line_command_map = (
- 'dircategory' => ''
-);
-
-# sc and var upcase.
-my @simple_quoted_commands = ('cite', 'code', 'command', 'env', 'file', 'kbd',
- 'option', 'samp');
-# slanted?
-my @asis_commands = ('asis', 'b', 'ctrl', 'dmn', 'i', 'math', 'sc', 't', 'r',
- 'slanted', 'var', 'titlefont', 'verb', 'clickstyle');
-my @chevron_commands = ('key', 'indicateurl');
-
-my %info_default_accent_commands = ();
-
-foreach my $accent_command ('tieaccent', 'dotless', keys(%unicode_accents),
keys(%accent_map))
-{
- $info_default_accent_commands{$accent_command} = 1;
- $style_map{$accent_command} = { 'function' => \&info_default_accent };
-}
-
-foreach my $command (keys(%style_map))
-{
- delete $style_map{$command}->{'attribute'} if
(exists($style_map{$command}->{'attribute'}));
- delete $style_map{$command}->{'quote'} if
(exists($style_map{$command}->{'quote'}));
- if (grep {$_ eq $command} @simple_quoted_commands)
- {
- delete $style_map{$command}->{'function'} if
(exists($style_map{$command}->{'function'}));
- $style_map{$command}->{'begin'} = '`';
- $style_map{$command}->{'end'} = "'";
- next;
- }
- elsif (grep {$_ eq $command} @asis_commands)
- {
- delete $style_map{$command}->{'function'} if
(exists($style_map{$command}->{'function'}));
- delete $style_map{$command}->{'begin'} if
(exists($style_map{$command}->{'begin'}));
- delete $style_map{$command}->{'end'} if
(exists($style_map{$command}->{'end'}));
- }
- if (grep {$_ eq $command} @chevron_commands)
- {
- delete $style_map{$command}->{'function'} if
(exists($style_map{$command}->{'function'}));
- $style_map{$command}->{'begin'} = '<';
- $style_map{$command}->{'end'} = '>';
- next;
- }
-}
-
-$style_map{'strong'}->{'begin'} = '*';
-$style_map{'strong'}->{'end'} = '*';
-$style_map{'dfn'}->{'begin'} = '"';
-$style_map{'dfn'}->{'end'} = '"';
-$style_map{'emph'}->{'begin'} = '_';
-$style_map{'emph'}->{'end'} = '_';
-
-
-my %info_default_leaf_command = ();
-foreach my $command ('uref', 'url', 'email', 'click')
-{
- $info_default_leaf_command{$command} = 1;
- if (defined ($style_map{$command}->{'args'}))
- {
- $style_map{$command}->{'orig_args'} = [
@{$style_map{$command}->{'args'}} ];
- }
- else
- {
- $style_map{$command}->{'orig_args'} = [ 'normal' ];
- }
- $style_map{$command}->{'args'} = [];
- foreach my $arg (@{$style_map{$command}->{'orig_args'}})
- {
- push @{$style_map{$command}->{'args'}}, 'keep';
- }
-}
-
-$style_map{'uref'}->{'function'} = \&info_default_uref;
-$style_map{'url'}->{'function'} = \&info_default_uref;
-$style_map{'email'}->{'function'} = \&info_default_email;
-
-foreach my $command (keys(%style_map))
-{
- $style_map_pre{$command} = {};
- $style_map_texi{$command} = {};
- foreach my $key (keys(%{$style_map{$command}}))
- {
- $style_map_pre{$command}->{$key} = $style_map{$command}->{$key};
- $style_map_texi{$command}->{$key} = $style_map{$command}->{$key};
- }
-}
-
-$special_list_commands{'itemize'} = {};
-my @info_default_normal_formats = ('table', 'vtable', 'ftable', 'enumerate',
- 'itemize');
-foreach my $format (@info_default_normal_formats, 'group', 'cartouche')
-{
- $format_map{$format} = '';
-}
-
-my %info_default_indented_commands;
-foreach my $command (keys (%{$complex_format_map}),
@info_default_normal_formats, 'quotation', 'deff_item', 'deff_itemx')
-{
- $info_default_indented_commands{$command} = 1;
-}
-
-my %info_default_format;
-foreach my $command (keys(%info_default_indented_commands), 'multitable',
'float', 'menu', 'flushright', 'flushleft', 'center')
-{
- $info_default_format{$command} = 1;
-}
-
-$info_default_indented_commands{'format'} = 0;
-$info_default_indented_commands{'smallformat'} = 0;
-
-my $info_default_end_sentence_character = quotemeta($punctuation_characters);
-my $info_default_after_punctuation_characters =
quotemeta($after_punctuation_characters);
-my $info_default_indent_length = 5;
-
-my %info_default_indent_format_length = ('enumerate' => 2,
- 'itemize' => 3,
- 'table' => 0,
- 'vtable' => 0,
- 'ftable' => 0,
- );
-
-my %default_info_level_to_symbol = (
- 0 => '*',
- 1 => '*',
- 2 => '=',
- 3 => '-',
- 4 => '.'
-);
-
-my $info_default_index_length_to_node = 41;
-
-my $info_default_listoffloat_caption_entry_length = 41;
-my $info_default_listoffloat_append = '...: ';
-
-push @command_handler_init, \&info_default_init_accent_enable_encoding;
-
-my %info_default_enable_encoding_accents;
-
-$style = \&info_default_style;
-$print_page_head = \&info_default_print_page_head;
-$toc_body = \&info_default_noop;
-$about_body = \&info_default_noop;
-$print_Footnotes = \&info_default_noop;
-$copying_comment = \&info_default_copying_comment;
-$element_heading = \&info_default_element_heading;
-$heading = \&info_default_heading;
-$normal_text = \&info_default_normal_text;
-$paragraph = \&info_default_paragraph;
-$preformatted = \&info_default_preformatted;
-$empty_preformatted = \&info_default_preformatted;
-$empty_line = \&info_default_empty_line;
-# maybe should not be called from the main program?
-$print_page_foot = \&info_default_print_page_foot;
-$print_Top_footer = \&info_default_print_Top_footer;
-$print_Top = \&info_default_print_section;
-$print_section = \&info_default_print_section;
-$end_section = \&info_default_end_section;
-$one_section = \&info_default_one_section;
-$begin_format_texi = \&info_default_begin_format_texi;
-$begin_style_texi = \&info_default_begin_style_texi;
-$begin_paragraph_texi = \&info_default_begin_paragraph_texi;
-$simple_command = \&info_default_simple_command;
-$thing_command = \&info_default_thing_command;
-$begin_special_region = \&info_default_begin_special_region;
-$end_special_region = \&info_default_end_special_region;
-$anchor_label = \&info_default_anchor_label;
-$element_label = \&info_default_noop;
-$menu_link = \&info_default_menu_link;
-$menu_command = \&info_default_menu_command;
-$complex_format = \&info_default_complex_format;
-$quotation = \&info_default_quotation;
-$unknown = \&info_default_misc_commands;
-$external_ref = \&info_default_external_ref;
-$internal_ref = \&info_default_internal_ref;
-$image = \&info_default_image;
-$image_files = \&info_default_image_files;
-$index_summary = \&info_default_index_summary;
-$summary_letter = \&info_default_summary_letter;
-$index_entry = \&info_default_index_entry;
-$index_letter = \&info_default_index_letter;
-$print_index = \&info_default_print_index;
-$index_entry_label = \&info_default_index_entry_label;
-$foot_section = \&info_default_foot_lines;
-$foot_line_and_ref = \&info_default_foot_line_and_ref;
-$footnote_texi = \&info_default_footnote_texi;
-$list_item = \&info_default_list_item;
-$format_list_item_texi = \&info_default_format_list_item_texi;
-$format = \&info_default_format;
-$tab_item_texi = \&info_default_tab_item_texi;
-$acronym_like = \&info_default_acronym_like;
-$sp = \&info_default_sp;
-$paragraph_style_command = \&info_default_paragraph_style_command;
-$cell = \&info_default_cell;
-$row = \&info_default_row;
-$table_list = \&info_default_table_list;
-$def_item = \&info_default_def_item;
-$def = \&info_default_def;
-$def_line = \&info_default_def_line;
-$float = \&info_default_float;
-$listoffloats_entry = \&info_default_listoffloats_entry;
-$listoffloats = \&info_default_listoffloats;
-$colon_command = \&info_default_colon_command;
-$raw = \&info_default_raw;
-$line_command = \&info_default_line_command;
-$element_file_name = \&info_default_element_file_name;
-
-#Â FIXME initialize
-my %info_default_state_map = ();
-my $info_default_out_file_nr = 1;
-my $info_default_dir_specification = '';
-my @info_default_pending_indirect = ();
-my @info_default_pending_footnotes = ();
-my $info_default_state_nr = 0;
-
-my %info_default_index_line_string_length = ();
-my %info_default_index_entries = ();
-my $info_default_footnote_index = 0;
-my $info_default_current_node = undef;
-
-#Â this is put in command_handler_init such that it sets things right
-#Â in case $ENABLE_ENCODING is set and haslead to modification of the
-#Â accent functions
-sub info_default_init_accent_enable_encoding()
-{
- return unless ($ENABLE_ENCODING);
- foreach my $key (keys(%unicode_accents), 'dotless')
- {
- $info_default_enable_encoding_accents{$key} = 1;
- $t2h_enable_encoding_default_accent{'normal'}->{$key} =
\&t2h_default_ascii_accent;
- $t2h_enable_encoding_default_accent{'texi'}->{$key} =
\&t2h_default_ascii_accent;
- $t2h_enable_encoding_default_accent{'pre'}->{$key} =
\&t2h_default_ascii_accent;
- $style_map{$key}->{'function'} = \&info_default_accent;
- $style_map_texi{$key}->{'function'} = \&info_default_accent;
- $style_map_pre{$key}->{'function'} = \&info_default_accent;
- }
-}
-
-sub info_default_uref($$)
-{
- shift;
- my $args = shift;
- my $url = shift @$args;
- my $text = shift @$args;
- my $replacement = shift @$args;
- #$url =~ s/\s*$//;
- #$url =~ s/^\s*//;
- $url = main::normalise_space($url);
- $replacement = '' if (!defined($replacement));
- $replacement = main::normalise_space($replacement);
- return $replacement if ($replacement ne '');
- $text = '' if (!defined($text));
- $text = main::normalise_space($text);
- return "`$url'" if ($text eq '');
- return "$text ($url)";
-}
-
-sub info_default_email($$)
-{
- my $command = shift;
- my $args = shift;
- my $mail = shift @$args;
- my $text = shift @$args;
- $mail = main::normalise_space($mail);
- $text = '' if (!defined($text));
- $text = main::normalise_space($text);
- $mail = "<$mail>";
- return $mail unless ($text ne '');
- return "$text $mail";
-}
-
-
-sub info_default_accent($$$)
-{
- my @args = @_;
- my $command = shift;
- my $args = shift;
- my $text = $args->[0];
- my $style_stack = shift;
- my $state = shift;
-
- my $result;
- if ($ENABLE_ENCODING and $info_default_enable_encoding_accents{$command})
- {
- $result = &t2h_enable_encoding_normal_accent(@args);
- }
- else
- {
- $result = &t2h_default_ascii_accent(@args);
- }
- if (scalar(@$style_stack) and
$info_default_accent_commands{$style_stack->[-1]})
- {
- return $result;
- }
- return info_default_store_text($state,$result,'accents_commands');
-# return '' if info_default_store_text($state,$result,'accents_commands');
-# return $result;
-}
-
-sub info_default_noop
-{
- return '';
-}
-
-sub info_default_copying_comment($$$$)
-{
- my $copying_lines = shift;
- my $copying_text = shift;
- my $copying_no_texi = shift;
- my $copying_simple_text = shift;
- return '' if ($copying_text eq '');
- return $copying_text;
-}
-
-sub info_default_count_lines($;$$)
-{
- my $text = shift;
- my $indent_length = shift;
- my $indentation_done = shift;
-
- my $blank_line;
- my $no_indentation = 0;
-
- if (!defined($indentation_done) or $indentation_done)
- {
- $no_indentation = 1;
- $indent_length = 0;
- }
- my @lines = split /^/, $text;
- # don't accept empty text.
- @lines = ('') if (address@hidden);
- my $line_passed = scalar(@lines);
- $line_passed-- if ($line_passed);
-
- my $end_of_line = 0;
- if (($#lines > 1) and !$end_of_line and ($lines[-1] !~ /\S/) and
($lines[-2] !~ /\S/))
- {
- $blank_line = 1;
- }
- my $last_line = $lines[-1];
-
- my $indented_text = shift (@lines);
-print STDERR "COUNT info_default_count_lines(i_done $no_indentation, i_l
$indent_length) i_t `$indented_text'\n";
- foreach my $line (@lines)
- {
-print STDERR "ZZZZZZZZZZZZZzz `$line'\n";
- if ($indent_length and $line =~ /\S/)
- {
- $indented_text .= ' ' x $indent_length . $line;
- }
- else
- {
- $indented_text .= $line;
- }
- }
- if (chomp($text))
- {
- $line_passed++;
- $end_of_line = 1;
- }
- return ($line_passed, $end_of_line, $last_line, $indented_text,
$blank_line);
-}
-
-sub info_default_get_state($)
-{
- my $state = shift;
- if (!exists $info_default_state_map{$state})
- {
-print STDERR "NEW state $info_default_state_nr\n";
- my ($current_command, $top_stack);
- $info_default_state_map{$state} = {};
- info_default_reset_state($info_default_state_map{$state});
- #Â since the page head always leave a blank line, and the state may be
- #Â used for text right after the page head, we set it to 1 here.
- #Â it may be wrong in other contexts, to be seen.
- $info_default_state_map{$state}->{'blank_line'} = 1;
- $info_default_state_map{$state}->{'only_spaces'} = 1;
- #Â this is the first line, so set to 1. This is reset later in
- #Â most cases, when a node is seen, but may still be useful in
- address@hidden, for example
- $info_default_state_map{$state}->{'line_count'} = 1;
- $info_default_state_map{$state}->{'nr'} = $info_default_state_nr;
- $info_default_state_map{$state}->{'state'} = $state;
- $info_default_state_map{$state}->{'multitable_stack'} = [];
- @{$info_default_state_map{$state}->{'align_stack'}} =
({'command'=>'normal'});
- $info_default_state_nr++;
- }
-print STDERR "RETURN state $state $info_default_state_map{$state}
$info_default_state_map{$state}->{'nr'}\n";
- return $info_default_state_map{$state};
-}
-
-sub info_default_reset_state($)
-{
- my $info_state = shift;
- $info_state->{'top'} = {};
- $info_state->{'current'} = $info_state->{'top'};
-}
-
-sub info_default_iterator_next($$$)
-{
- my $current_command = shift;
- my $command_index = shift;
- my $command_close = shift;
-print STDERR "NNNNNNNNNNNNNN iterator_next current $current_command idx
$command_index close $command_close\n";
-
- my $sub_command = $current_command->{'content'}->[$command_index];
-
- if ($sub_command->{'content'} and !$command_close)
- {
- return ($sub_command, 0, 0);
- }
-
- if ($current_command->{'content'}->[$command_index+1])
- {
- return ($current_command, $command_index+1, 0);
- }
- elsif (defined($current_command->{'parent'}))
- {
- return ($current_command->{'parent'},
$current_command->{'index_in_parent'}, 1);
- }
- else
- {
- return (undef, undef, undef);
- }
-}
-
-sub info_default_next($$$)
-{
- my $current = shift;
- my $index = shift;
- my $close = shift;
-
- my $text;
- my $command;
-
- my ($current_next, $index_next, $close_next) =
info_default_iterator_next($current, $index, $close);
- return ($current_next, $index_next, $close_next, $text, $command) if
(!defined($current_next));
-
- my $content = $current_next->{'content'}->[$index_next];
- $command = $content->{'command'} if (defined($content->{'command'}));
- if ($close_next)
- {
- return ($current_next, $index_next, $close_next, $content->{'end'},
$command);
- }
- if (defined($content->{'text'}))
- {
- return ($current_next, $index_next, $close_next, $content->{'text'},
$command);
- }
- if (defined($content->{'begin'}))
- {
- $text = $content->{'begin'};
- }
- if (defined($content->{'end'}) and !defined($content->{'content'}))
- {
- if (!defined($text))
- {
- $text = $content->{'end'};
- }
- else
- {
- $text .= $content->{'end'};
- }
- }
- return ($current_next, $index_next, $close_next, $text, $command);
-}
-
-
-#Â Beware that there is a pending word if the text doesn't end with
-# a space
-sub info_default_process_text($$$$$$$;$)
-{
- my $text = shift;
- my $line_char_counter = shift;
- my $pending_spaces = shift;
- my $pending_word = shift;
- my $indent_length = shift;
- my $in_para = shift;
- my $max_column = shift;
-# indentation for the lines except for the first one
- my $indent_length_next = shift;
-
- $indent_length_next = $indent_length if (!defined($indent_length_next));
-
- $indent_length = 0 if (!defined($indent_length));
-
- my $line_passed = 0;
- my $result = '';
-
-print STDERR "process_text(indent($indent_length), in_para $in_para spaces
`$pending_spaces') line_char_counter $line_char_counter `$text'\n";
- if (!$in_para)
- { #Â should never be in preformatted, but in string processing
- my $chomped_text = $text;
- chomp($chomped_text);
- if ($indent_length > $line_char_counter and $chomped_text ne '')
- {
- $text = ' ' x ($indent_length - $line_char_counter) . $text;
- }
- $line_char_counter += length($text);
- if (chomp($chomped_text))
- {
- $line_passed = 1;
- $line_char_counter = 0;
- }
- return ($line_char_counter, $pending_spaces, $pending_word,
$line_passed, $text);
- }
-
- while ($text ne '')
- {
- my $pending_word_text = 'UNDEF';
-$pending_word_text = $pending_word if (defined($pending_word));
-
-#print STDERR "l_c_c $line_char_counter pending_word $pending_word_text,
pending_spaces `$pending_spaces', result `$result'\n";
- if ($text =~ s/^(\s+)//)
- {
- my $new_spaces = $1;
- #Â in general there are no end of lines in the lines cut. However, it
- #Â may happen with @* in @def* lines
- my @lines = split /^/, $new_spaces;
- my $eol_spaces;
- if (@lines > 1)
- {
- $new_spaces = pop @lines;
- $eol_spaces = join ("", @lines);
-print STDERR "EOL_SPACES[$line_char_counter](+$pending_spaces)
`$eol_spaces'\n";
- }
- if (defined($pending_word))
- {
- if ($indent_length > $line_char_counter + length($pending_spaces))
- {
- $pending_spaces = ' ' x ($indent_length - $line_char_counter)
. $pending_spaces;
- }
- $result .= $pending_spaces . $pending_word;
- $line_char_counter +=
length($pending_spaces)+length($pending_word);
- $pending_spaces = $new_spaces;
- $pending_word = undef;
- }
- elsif (!$eol_spaces)
- {
- $pending_spaces .= $new_spaces;
- }
- if ($eol_spaces)
- {
- #$result .= $pending_spaces . $eol_spaces;
- $result .= $eol_spaces;
- $line_passed += scalar(@lines);
- $indent_length = $indent_length_next;
- $line_char_counter = 0;
- #$pending_spaces = $new_spaces;
- $pending_spaces = '';
- }
- if (length($pending_spaces) + $line_char_counter > $max_column)
- {
- $pending_spaces = '';
- $result .= "\n";
- $line_passed++;
- $indent_length = $indent_length_next;
- $line_char_counter = 0;
- }
- }
- elsif ($text =~ s/^([^\s]+)//)
- {
- my $word = $1;
- $pending_word = '' if (!defined($pending_word));
- $pending_word .= $word;
- # The $line_char_counter != 0 is here to cope with the case of a
- # word longer than $line_char_counter followed by more letters:
- #Â a line would be passed each time some text is appended.
- if ((length($pending_spaces)+length($pending_word) +
$line_char_counter > $max_column) and $line_char_counter != 0)
- {
- $pending_spaces = '';
- $result .= "\n";
- $line_passed++;
- $indent_length = $indent_length_next;
- $line_char_counter = 0;
- }
- }
- }
- return ($line_char_counter, $pending_spaces, $pending_word, $line_passed,
$result)
-}
-
-sub info_default_skip_spaces($$$)
-{
- my $current = shift;
- my $index = shift;
- my $close = shift;
-
- print STDERR "SKIP_SPACES\n";
- while(1)
- {
- my ($current_next, $index_next, $close_next) =
info_default_iterator_next($current, $index, $close);
- return if ($close_next or (!defined($current_next)));
- my $content = $current_next->{'content'}->[$index_next];
- if (defined($content->{'begin'}))
- {
- $content->{'begin'} =~ s/^\s*//;
-print STDERR "SKIP_SPACES begin\n";
- return if ($content->{'begin'} ne '');
- }
- if (defined($content->{'content'}) or
defined($content->{'format_name'})
- or $content->{'definition_line'})
- { #Â non empty commands stop space skipping, even if they contain
- # only spaces, like @asis{ }
- #Â also for item(x) that have format_name defined
-print STDERR "SKIP_SPACES command?\n";
- return;
- }
- if (defined($content->{'text'}))
- {
-print STDERR "SKIP_SPACES text\n";
- $content->{'text'} =~ s/^\s*//;
- return if ($content->{'text'} ne '');
- }
- if (defined($content->{'end'}))
- {
-print STDERR "SKIP_SPACES end\n";
- $content->{'end'} =~ s/^\s*//;
- return if ($content->{'end'} ne '');
- }
- ($current, $index, $close) = ($current_next, $index_next, $close_next);
- }
-}
-
-sub info_default_store_pending($$$;$)
-{
- my $line_char_counter = shift;
- my $pending_spaces = shift;
- my $pending_word = shift;
- my $indent_length = shift;
-
- $indent_length = 0 if (!defined($indent_length));
- my $indent_text = '';
- $indent_text = ' ' x $indent_length;
-
- my $pending_word_text = 'undef';
- $pending_word_text = $pending_word if (defined($pending_word));
- print STDERR "store_pending(spaces `$pending_spaces',
indent($indent_length) `$indent_text' word `$pending_word_text'\n";
- my $result = $pending_spaces;
- $pending_spaces = '';
- if (defined($pending_word))
- {
- $result .= $pending_word;
- $pending_word = undef;
- }
-
- my $chomped_result = $result;
- chomp ($chomped_result);
- if ($line_char_counter == 0 and $chomped_result ne '')
- {
- $result = $indent_text . $result;
- }
-
- $line_char_counter += length($result);
- return ($line_char_counter, $pending_spaces, $pending_word, $result);
-}
-
-sub info_default_output($)
-{
- my $info_state = shift;
- my $result = '';
- print STDERR "Storing the stack\n";
- #print STDERR "" . Data::Dumper->Dump([$info_state->{'top'}]);
- my ($characters_count, $lines_count);
- ($characters_count, $result, $lines_count) =
info_default_process_content($info_state->{'top'}, $info_state);
- $info_state->{'offset_in_file'} += $characters_count;
- $info_state->{'line_count'} += $lines_count;
- info_default_reset_state($info_state)
- if (!defined($info_state->{'current'}->{'command'}));
- return $result;
-}
-
-
-sub info_default_process_content($$)
-{
- my $current_command = shift;
- my $info_state = shift;
-
- my $length = 0;
- my $result = '';
-
- my $line_char_counter = 0;
- my $all_line_passed = 0;
-
- my $pending_spaces = '';
- my $pending_word;
- my $preformatted = 0;
- my $indent_level = 0;
- my $item_pending;
- my $in_exdent = 0;
- my $in_para = 0;
- my $table_item_line = 0;
- my $in_table_item = 0;
- my $max_column = get_conf('fillcolumn');
- my $direntry = 0;
- my $preformatted_format = 0;
-
- #Â for formats that needs to process a full line (center and flushright)
- # to know the line length before outputing
- my $current_line = undef;
-
- my ($current, $index, $close) = ($current_command, 0, 0);
-
- #print STDERR "info_default_process_content: $current_command\n";
- while(1)
- {
- last if (!defined($current));
- my $content = $current->{'content'}->[$index];
- my $text_added = '';
- my $item_line_added = 0;
- my $indentation_done = 0;
- my $text_item_pending = '';
- $text_item_pending = $item_pending if (defined($item_pending));
- my $text_length = '';
- $text_length = "$content->{'text'}" if defined($content->{'text'});
- my $text_command = '';
- $text_command = $content->{'command'} if defined($content->{'command'});
- my $in_node_count = 0;
- $in_node_count = $info_state->{'line_count'} if
defined($info_state->{'line_count'});
- print STDERR
"($text_command|$text_length|$close|${all_line_passed}+$in_node_count|l_c_cnt
$line_char_counter) prfrmted $preformatted para $in_para indent_lvl
$indent_level in_exdent $in_exdent only_spaces $info_state->{'only_spaces'}
blank_line $info_state->{'blank_line'} table_item_line $table_item_line
in_table_item $in_table_item item_pending $text_item_pending\n";
- my $pending_word_text = 'undef';
- $pending_word_text = "`$pending_word'" if (defined($pending_word));
- print STDERR " spaces: `$pending_spaces' word: $pending_word_text\n";
-
- my $indent_length = $indent_level * $info_default_indent_length;
- my $indent_length_next_line;
- #Â indent_length is also set here for table @item so in that case
- #Â $info_default_indent_format_length{$item_pending} is not taken
- #Â into account, luckily it is 0.
- $indent_length = ($indent_level -1) * $info_default_indent_length
- if ($indent_level and ($in_exdent or $table_item_line));
- my $item_indent_length = 0;
- if ($item_pending)
- {
- $indent_length_next_line = $indent_length;
- $indent_length = ($info_default_indent_format_length{$item_pending}
- +($indent_level -1)* $info_default_indent_length);
- }
-
- if ($close)
- {
- if (defined($content->{'end'}))
- {
- $text_added .= $content->{'end'};
- }
- if ($info_default_indented_commands{$content->{'command'}})
- {
- $indent_level--;
- if ($indent_level > 0 and !$info_state->{'blank_line'} and
$content->{'command'} !~ /^deff_item/ and !$preformatted)
- {
- $text_added .= "\n";
- }
- #Â this nullify a potential noindent in a random format
- $info_state->{'indent_para'} = undef;
- }
- elsif ($complex_format_map->{$content->{'command'}} or
$content->{'command'} eq 'cartouche')
- {
- if (!$info_state->{'blank_line'} and
$info_state->{'only_spaces'} and ($indent_level > 0) and !$preformatted)
- {
- $text_added .= "\n";
- }
- }
- if ($complex_format_map->{$content->{'command'}} and
$content->{'content'})
- {
- $preformatted_format--;
- }
- if ($content->{'command'} eq 'paragraph' and
$info_state->{'align_stack'}->[-1]->{'command'} eq 'normal')
- {
- #Â if there is no space at the end of a paragraph, there may be
- #Â pending text, for example, if there is an ending line like
- #Â Some address@hidden a comment
- my $pending;
- ($line_char_counter, $pending_spaces, $pending_word, $pending) =
info_default_store_pending($line_char_counter, $pending_spaces, $pending_word,
$indent_length);
- $text_added .= $pending if (defined($pending));
- $text_added =~ s/\s*$//;
- $pending_spaces = '';
- $in_para = 0;
- $info_state->{'indent_para'} = undef;
- $text_added .= "\n" unless (($line_char_counter +
length($text_added)) == 0);
- }
- elsif ($content->{'command'} eq 'preformatted')
- {
- #Â if preformatted doesn't end with a newline, it is added here
- $text_added .= "\n" unless ($line_char_counter == 0);
- $preformatted--;
- }
- elsif ($content->{'command'} eq 'menu')
- {
- $text_added .= "\n" unless ($info_state->{'blank_line'});
- }
- elsif ($content->{'command'} eq 'float')
- {
- $text_added = "\n" . $text_added unless
($info_state->{'blank_line'});
- }
- elsif ($paragraph_style{$content->{'command'}})
- {
- my $popped = pop @{$info_state->{'align_stack'}};
- print STDERR "BUG: align_stack, popped $popped->{'command'} ne
command $content->{'command'}\n" if ($popped->{'command'} ne
$content->{'command'});
- }
- elsif ($content->{'command'} eq 'multitable')
- {
- my $multitable = pop @{$info_state->{'multitable_stack'}};
- $max_column = $multitable->{'max_column_kept'};
- $result = $multitable->{'result_kept'};
- $line_char_counter = $multitable->{'line_char_counter_kept'};
- $all_line_passed = $multitable->{'all_line_passed_kept'};
- $length = $multitable->{'length_kept'};
- $info_state->{'offset_in_file'} =
$multitable->{'offset_in_file_kept'};
- $info_state->{'line_count'} = $multitable->{'line_count_kept'};
- print STDERR "MULTITABLE close, lines:
$multitable->{'line_count_kept'} + $all_line_passed\n";
- foreach my $anchor_and_index (@{$multitable->{'anchors'}},
@{$multitable->{'index_entries'}})
- {
- $anchor_and_index->{'line_nr'} +=
$multitable->{'line_count_kept'} + $all_line_passed;
- }
- if (! scalar(@{$info_state->{'multitable_stack'}}))
- {
- print STDERR "MULTITABLE close, lengths:
$multitable->{'offset_in_file_kept'} + $length\n";
- foreach my $anchor (@{$multitable->{'anchors'}})
- {
- $anchor->{'info_offset'} +=
$multitable->{'offset_in_file_kept'} + $length;
- }
- }
- else
- {
- push
@{$info_state->{'multitable_stack'}->[-1]->{'anchors'}},
@{$multitable->{'anchors'}};
- push
@{$info_state->{'multitable_stack'}->[-1]->{'index_entries'}},
@{$multitable->{'index_entries'}};
- }
- $text_added .= $multitable->{'result'};
- }
- elsif ($content->{'command'} eq 'multitable_cell')
- {
- my $cell =
$info_state->{'multitable_stack'}->[-1]->{'cells'}->[-1];
- $cell->{'result'} = $result;
- $cell->{'length'} = $length;
- $cell->{'line_passed'} = $all_line_passed;
- }
- elsif ($content->{'command'} eq 'direntry')
- {
- $direntry--;
- #Â this has to be done here, otherwise, at the end, $direntry
- #Â would be 0
- $info_default_dir_specification .= $text_added;
- $text_added = '';
- }
- elsif ($content->{'command'} eq 'multitable_row')
- {
- my $multitable = $info_state->{'multitable_stack'}->[-1];
- my $row_length = 0;
- my $row = '';
- my $max_lines = 0;
- my $cell_beginning = 0;
- my @anchor_lines_array;
- my $cell_idx = 0;
- my @anchors;
- my @indices;
- foreach my $cell (@{$multitable->{'cells'}})
- {
- $cell->{'beginning'} = $cell_beginning;
- $cell_beginning += $cell->{'cell_width'}+1;
- @{$cell->{'lines'}} = split /^/, $cell->{'result'};
- $max_lines = scalar(@{$cell->{'lines'}}) if
(scalar(@{$cell->{'lines'}}) > $max_lines);
- foreach my $anchor (@{$cell->{'anchors'}})
- {
- push @{$anchor_lines_array[$anchor->{'line_nr'}]},
$anchor;
- $anchor->{'cell_idx'} = $cell_idx;
- push @anchors, $anchor;
- }
- push @indices, @{$cell->{'index_entries'}};
- $cell_idx++;
- }
- my $previous_last_cell = scalar(@{$multitable->{'cells'}});
- print STDERR "ROW cell_beginning $cell_beginning, max_lines
$max_lines, previous_last_cell $previous_last_cell\n";
- for (my $line_idx = 0; $line_idx < $max_lines; $line_idx++)
- {
- my $length = 0;
- my $line = '';
- #Â determine the last cell in the line, to fill spaces in
- # cells preceding that cell on the line
- my $last_cell = 0;
- for (my $cell_idx = 0; $cell_idx < $previous_last_cell;
$cell_idx++)
- {
- $last_cell = $cell_idx+1 if
(defined($multitable->{'cells'}->[$cell_idx]->{'lines'}->[$line_idx]));
- }
- print STDERR " L(last_cell $last_cell): $line_idx\n";
- for (my $cell_idx = 0; $cell_idx < $last_cell; $cell_idx++)
- {
- my $cell_text =
$multitable->{'cells'}->[$cell_idx]->{'lines'}->[$line_idx];
- print STDERR " C($cell_idx) ";
- if (defined($cell_text))
- {
- chomp($cell_text);
- print STDERR "$cell_text";
- $line .= $cell_text;
- $length += length($cell_text);
- }
- if ($cell_idx+1 < $last_cell)
- {
- if ($length <
$multitable->{'cells'}->[$cell_idx+1]->{'beginning'})
- {
- my $spaces = ' ' x
($multitable->{'cells'}->[$cell_idx+1]->{'beginning'} - $length);
- $length += length($spaces);
- $line .= $spaces;
- print STDERR " Csp($length) `$spaces'";
- }
- }
- }
- if (defined($anchor_lines_array[$line_idx]))
- {
- foreach my $anchor (@{$anchor_lines_array[$line_idx]})
- {
- my $anchor_position = $anchor->{'line_char_counter'}
+ $multitable->{'cells'}->[$anchor->{'cell_idx'}]->{'beginning'};
- if ($anchor_position > $length)
- {
- my $spaces = ' ' x ($anchor_position - $length);
- $line .= $spaces;
- $length += length($spaces);
- }
- $anchor->{'info_offset'} = $anchor_position +
$row_length + $multitable->{'length'};
- print STDERR "ROW anchor close:
anchor[$anchor->{'cell_idx'}]($multitable->{'cells'}->[$anchor->{'cell_idx'}]->{'beginning'}+$anchor->{'line_char_counter'})
$anchor_position $anchor->{'info_offset'}\n";
- $anchor->{'line_char_counter'} = $anchor_position;
- }
- }
- $line .= "\n";
- $row_length += length($line);
- print STDERR " ($length,".length($line).") $line";
- $row .= $line;
- $previous_last_cell = $last_cell;
- }
- foreach my $anchor_and_index (@anchors, @indices)
- {
- $anchor_and_index->{'line_nr'} +=
$multitable->{'line_count'};
- print STDERR "ROW close: new line count:
$anchor_and_index->{'line_nr'} + \n";
- }
- if ($content->{'item_command'} eq 'headitem')
- {
- # at this point cell_beginning is at the beginning of
- #Â the cell following the end of the table -> full width
- my $line = '-' x $cell_beginning . "\n";
- $row .= $line;
- $row_length += length($line);
- }
- print STDERR "ROW_LENGTH $row_length\n";
- $multitable->{'result'} .= $row;
- $multitable->{'length'} += $row_length;
- $multitable->{'line_count'} += $max_lines;
- $multitable->{'cells'} = [];
- push @{$multitable->{'anchors'}}, @anchors;
- push @{$multitable->{'index_entries'}}, @indices;
- }
- }
- else
- {
- if ($content->{'command'})
- {
- my $pending_added_length = 0;
- if ($content->{'command'} eq 'anchor' or $content->{'command'}
eq 'image' or $content->{'command'} eq 'index_command' or $content->{'command'}
eq 'sp')
- {
- my $pending;
- ($line_char_counter, $pending_spaces, $pending_word,
$pending) = info_default_store_pending($line_char_counter, $pending_spaces,
$pending_word, $indent_length);
- #Â here spaces out of any environment are ignored.
- if ($in_para or $preformatted or $pending =~ /\S/)
- { #Â this has to be done before the anchor related code
- #Â to have the right count.
- # FIXME this is wrong if an end of line was passed.
- # in that case line_char_counter has been increased and
- # $pending ends with an end of line
- $pending_added_length += length($pending);
- $text_added .= $pending;
- }
- }
- if ($content->{'command'} eq 'anchor' or ($content->{'command'}
eq 'float' and $content->{'anchor_reference'}))
- {
-print STDERR "anchor: offset_in_file $info_state->{'offset_in_file'},
line_count $info_state->{'line_count'}, line_char_counter $line_char_counter
pending_added_length $pending_added_length\n";
- $content->{'anchor_reference'}->{'info_offset'} = $length +
$info_state->{'offset_in_file'} + $pending_added_length;
- $content->{'anchor_reference'}->{'line_nr'} =
$all_line_passed + $info_state->{'line_count'};
- $content->{'anchor_reference'}->{'line_char_counter'} =
$line_char_counter + $pending_added_length;
- if (@{$info_state->{'multitable_stack'}})
- {
- push
@{$info_state->{'multitable_stack'}->[-1]->{'cells'}->[-1]->{'anchors'}},
$content->{'anchor_reference'};
- }
- push @{$info_state->{'pending_tags'}},
$content->{'anchor_reference'};
- push @{$info_state->{'align_stack'}->[-1]->{'anchors'}},
$content->{'anchor_reference'} if
($info_state->{'align_stack'}->[-1]->{'command'} eq 'center' or
$info_state->{'align_stack'}->[-1]->{'command'} eq 'flushright');
- }
- elsif ($content->{'command'} eq 'index_label')
- {
- my $index_line_nr = $all_line_passed +
$info_state->{'line_count'};
- my $index_name = $content->{'index_name'};
- $info_default_index_line_string_length{$index_name} =
length($index_line_nr)
- if
(!defined($info_default_index_line_string_length{$index_name}) or
$info_default_index_line_string_length{$index_name} < length($index_line_nr));
-print STDERR "RRRRRRRRRRRRR $content->{'index_entry_reference'}->{'texi'}
name: $index_name line: $index_line_nr max:
$info_default_index_line_string_length{$index_name}\n";
- my $index_ref = { 'index_entry_reference' =>
$content->{'index_entry_reference'}, 'line_nr' => $index_line_nr, 'index_name'
=> $index_name };
-print STDERR "INDEX($index_name) line $index_line_nr\n";
-
$info_default_index_entries{$content->{'index_entry_reference'}} = $index_ref;
- if (@{$info_state->{'multitable_stack'}})
- {
- push
@{$info_state->{'multitable_stack'}->[-1]->{'cells'}->[-1]->{'index_entries'}},
$index_ref;
- }
- push @{$info_state->{'pending_index_entries'}}, $index_ref;
- }
- elsif ($content->{'command'} eq '*' and !$preformatted)
- {
- if (defined($pending_word))
- {
- $text_added .= $pending_spaces . $pending_word;
- $pending_word = undef;
- }
- #Â spaces preceding @* are skipped
- $pending_spaces = '';
- $text_added .= $content->{'text'};
- #Â just like following spaces
- info_default_skip_spaces($current, $index, $close);
- goto new_text;
- }
- elsif ($content->{'command'} eq 'paragraph' and
$info_state->{'align_stack'}->[-1]->{'command'} eq 'normal')
- {
- #Â empty paragraph
- goto new_text if (!$content->{'content'});
- my $paragraphindent = get_conf('paragraphindent');
- $paragraphindent = 0 if ($paragraphindent eq 'none');
- if ($paragraphindent ne 'asis')
- {
- info_default_skip_spaces($current, $index, $close);
- }
- if ($paragraphindent ne 'asis' and $paragraphindent and
$line_char_counter == 0 and !($indent_level) and
!scalar(@{$info_state->{'multitable_stack'}}) and ($info_state->{'indent_para'}
or (!defined($info_state->{'indent_para'}) and
($content->{'paragraph_in_element_nr'} or (get_conf('firstparagraphindent') eq
'insert')))))
- {
- $text_added .= ' ' x $paragraphindent;
- }
- $in_para = 1;
- }
- elsif ($content->{'command'} eq 'preformatted')
- {
- $preformatted++ if ($content->{'content'});
- }
- elsif ($content->{'command'} eq 'exdent')
- {
- # if an end of line is added, in_exdent is set to 2 and
- #Â set to one when processing the end of line that was just
- #Â added, and set to 0 at the end of the line.
- #Â if there is no end of line added, it is only set to 1.
- if ($line_char_counter != 0)
- {
- $text_added .= "\n";
- $in_exdent = 2;
- }
- else
- {
- $in_exdent = 1;
- }
- #goto new_text;
- }
- elsif ($content->{'command'} eq 'indent')
- {
- $info_state->{'indent_para'} = 1;
- }
- elsif ($content->{'command'} eq 'noindent')
- {
- $info_state->{'indent_para'} = 0;
- }
- elsif ($content->{'command'} eq 'image' or $content->{'command'}
eq 'sp')
- {
- $text_added .= $content->{'text'};
- goto new_text;
- }
- elsif ($content->{'definition_line'})
- {
-
- my $dummy_line_passed;
-print STDERR "BUG: defined pending_word before DEFINITION_LINE\n" if
defined($pending_word);
-print STDERR
"DEFINITION_LINE($line_char_counter,$pending_spaces,$indent_length,$in_para,$max_column):
$content->{'text'}";
- ($line_char_counter, $pending_spaces, $pending_word,
$dummy_line_passed, $text_added) =
info_default_process_text($content->{'text'}, $line_char_counter,
$pending_spaces, $pending_word, $indent_length, 1, $max_column,
$indent_length+2*$info_default_indent_length);
- $text_added .= $pending_spaces;
- $pending_spaces = '';
- print STDERR
"DEFINITION_LINE($line_char_counter,$pending_spaces) -> $text_added";
-print STDERR "BUG: defined pending_word after DEFINITION_LINE\n" if
defined($pending_word);
- $indentation_done = 1;
-
- goto new_text;
- }
- elsif (($content->{'command'} eq 'item' or $content->{'command'}
eq 'itemx') and exists $format_map{$content->{'format_name'}})
- {
- $item_pending = $content->{'format_name'};
- #if (!$info_state->{'blank_line'} and $content->{'command'}
eq 'item')
- my $first_item = 0;
-
- if ($content->{'command'} eq 'item')
- {
- if (!defined($content->{'parent'}->{'item_nr'}))
- {
- $content->{'parent'}->{'item_nr'} = 1;
- $first_item = 1;
- }
- else
- {
- $content->{'parent'}->{'item_nr'}++;
- }
- }
-
- if ($item_pending =~ /table$/)
- {
- $table_item_line = 1;
- $in_table_item = 0;
-print STDERR "DDDDDDDDDDDDDDDD $content->{'command'} $first_item or
$indent_level $content->{'parent'}->{'command'}\n";
- }
- if (!$info_state->{'blank_line'} and ($content->{'command'}
ne 'itemx') and (!$first_item or $indent_level != 1))
- {
- $text_added = "\n" . $text_added;
- $item_line_added = 1;
- }
- # one less indentation level and no line break
- #Â adding item_line_added allows the table_item_line to
- #Â still be active after the additional blank line
- $table_item_line = 1+$item_line_added if ($item_pending =~
/table$/);
- }
- elsif ($content->{'command'} eq 'menu' or $content->{'command'}
eq 'listoffloats' or $content->{'heading_command'})
- {
- $text_added .= "\n" unless ($info_state->{'blank_line'});
- }
- elsif ($content->{'command'} eq 'direntry')
- {
- if ($content->{'content'})
- {
- $direntry++;
- }
- }
- elsif ($paragraph_style{$content->{'command'}})
- {
- push @{$info_state->{'align_stack'}}, {'command' =>
$content->{'command'}};
- }
- elsif ($content->{'command'} eq 'verbatim' or
$content->{'command'} eq 'verbatiminclude')
- {
- #Â $preformatteed cannot be used here since preformatted
- #Â is closed before a verbatim
- if (!$preformatted_format and $indent_level != 0)
- {
- if (!$info_state->{'blank_line'} and
$info_state->{'only_spaces'})
- {
- $text_added .= "\n";
- }
- my $verb_text = $content->{'text'};
- my ($line_passed, $end_of_line, $last_line,
$text_indented, $blank_line) = info_default_count_lines($verb_text);
- $content->{'text'} .= "\n" unless ($blank_line or
($last_line =~ /^\s*$/));
- }
- }
- elsif ($content->{'command'} eq 'multitable')
- {
- my $multitable = {
- 'offset_in_file_kept' => $info_state->{'offset_in_file'},
- 'line_count_kept' => $info_state->{'line_count'},
- 'columns_size' => [ @{$content->{'columns_size'}}
],
- 'result' => '',
- 'length' => 0,
- 'line_count' => 0,
- 'result_kept' => $result,
- 'length_kept' => $length,
- 'all_line_passed_kept' => $all_line_passed,
- 'line_char_counter_kept' => $line_char_counter,
- 'max_column_kept' => $max_column,
- };
- push @{$info_state->{'multitable_stack'}}, $multitable;
- $info_state->{'offset_in_file'} = 0;
- $info_state->{'line_count'} = 0;
- }
- elsif ($content->{'command'} eq 'multitable_row')
- {
- $info_state->{'multitable_stack'}->[-1]->{'cell_index'} = -1;
- }
- elsif ($content->{'command'} eq 'multitable_cell')
- {
- my $multitable = $info_state->{'multitable_stack'}->[-1];
- $multitable->{'cell_index'}++;
- my $cell_width =
$content->{'parent'}->{'parent'}->{'columns_size'}->[$multitable->{'cell_index'}];
- #$max_column = $cell_width-1;
- $max_column = $cell_width -2;
- my $cell = {'cell_width' => $cell_width, 'index_entries' =>
[], 'anchors' => []};
- push @{$multitable->{'cells'}}, $cell;
- $result = '';
- $length = 0;
- $all_line_passed = 0;
- $line_char_counter = 0;
- if (!$content->{'content'})
- {# empty cell
- $cell->{'result'} = $result;
- $cell->{'length'} = $length;
- $cell->{'line_passed'} = $all_line_passed;
- }
- #info_default_skip_spaces($current, $index, $close);
- }
- if ($info_default_indented_commands{$content->{'command'}})
- {
- if ($content->{'command'} =~ /^deff_item/)
- {
- info_default_skip_spaces($current, $index, $close);
- }
- elsif (!$info_state->{'blank_line'} and
$info_state->{'only_spaces'} and ($indent_level != 0) and !$preformatted)
- {
- $text_added .= "\n";
- }
- #Â there is no close if !$content->{'content'}
- $indent_level++ if ($content->{'content'});
- }
- elsif ($complex_format_map->{$content->{'command'}} or
$content->{'command'} eq 'cartouche')
- {
- if (!$info_state->{'blank_line'} and
$info_state->{'only_spaces'} and ($indent_level != 0) and !$preformatted)
- {
- $text_added .= "\n";
- }
- }
- if ($complex_format_map->{$content->{'command'}} and
$content->{'content'})
- {
- $preformatted_format++;
- }
- }
-
- if (defined($content->{'text'}))
- {
- if ($in_para and !$in_exdent)
- {
-print STDERR "IN_PARA text\n";
- my $new_text = $content->{'text'};
- if ((!defined($content->{'command'}) or
$content->{'command'} ne ':') and $new_text =~
/([$info_default_end_sentence_character])([$info_default_after_punctuation_characters]*)(\s*)$/)
- {
- #Â the info_default_after_punctuation_characters should
- #Â always be in the same text element.
- if (chomp($new_text))
- {
- $new_text =~ s/(\s*)$/ /;
- }
- else
- {
- # spaces may be in following commands
- my ($current_next, $index_next, $close_next,
$text_next, $command_next) = info_default_next ($current, $index, $close);
- while (1)
- {
- last if (!defined($current_next) or
(defined($command_next) and $command_next eq '*'));
- if ($text_next =~ /\S/)
- {
- last;
- }
- else
- {
- if (chomp($text_next))
- {
- info_default_skip_spaces($current,
$index, $close);
- $new_text =~ s/(\s*)$/ /;
- last;
- }
- }
- ($current_next, $index_next, $close_next,
$text_next, $command_next) = info_default_next ($current_next, $index_next,
$close_next);
- }
- }
- print STDERR "KKKKKKKKKKKK `$1' `$2' `$3'";
- }
- elsif (chomp($new_text))
- {
- $new_text =~ s/(\s*)$/ /;
- # if ($new_text =~
/[$info_default_end_sentence_character] $/)
- # {
- # $new_text .= ' ';
- # }
- }
- $text_added .= $new_text;
- } # ignore spaces outside of paragraphs and preformatted
- elsif ($preformatted or
$info_state->{'align_stack'}->[-1]->{'command'} ne 'normal')
- {
-print STDERR "IN_PREFORMATTED or ALIGN text\n";
- $text_added .= $content->{'text'};
- }
- else
- {
- my $chomped_text = $content->{'text'};
- if ($chomped_text !~ /\S/ and chomp($chomped_text) and
!$item_pending)
- {
- if ($in_table_item and $info_state->{'only_spaces'})
- {
- #Â in a blank_line
-print STDERR "IN_ITEM ignored: `$content->{'text'}'\n";
- }
- elsif (!$info_state->{'blank_line'} or
!$info_state->{'only_spaces'})
- {
-print STDERR "IN_ADDING_BLANK_LINE because no line before or text before\n";
- $text_added .= "\n";
- }
- else
- {
-print STDERR "IN_NOT_ADDING_BLANK_LINE\n";
- }
- }
- else
- { #Â exdent, item not in paragraph nor in preformatted
-print STDERR "NOWHERE and not end of line (or item_pending)
`$content->{'text'}'\n";
- $text_added .= $content->{'text'};
- }
- }
-# unless (!defined($line_char_counter) and !$preformatted and
$content->{'text'} =~ /^\s*$/);
- }
- else
- {
- if (defined($content->{'begin'}))
- {
- $text_added .= $content->{'begin'};
- }
- #Â command that won't be closed, so the end has to be added
- #Â here. It should mostly happen for empty style @-commands.
- if (defined($content->{'end'}) and
!defined($content->{'content'}))
- {
- $text_added .= $content->{'end'};
- }
- }
- }
- if (!$preformatted and !$in_exdent and
$info_state->{'align_stack'}->[-1]->{'command'} eq 'normal' and $in_para)
- #if (!$preformatted and !$in_exdent)
- {
- #Â the line_passed returned here are not used, since they are
computed
- #Â below.
- $indentation_done = 1;
- my $dummy_line_passed;
- ($line_char_counter, $pending_spaces, $pending_word,
$dummy_line_passed, $text_added) = info_default_process_text($text_added,
$line_char_counter, $pending_spaces, $pending_word, $indent_length, $in_para,
$max_column, $indent_length_next_line) if ($text_added ne '');
- }
- elsif ($info_state->{'align_stack'}->[-1]->{'command'} ne 'center' and
$info_state->{'align_stack'}->[-1]->{'command'} ne 'flushright')
- {
-
- my $chomped_text = $text_added;
- #if (chomp($chomped_text))
- #{
- # $in_exdent = 0;
- #}
- chomp($chomped_text);
-print STDERR "NOT IN PARA text_added `$text_added' line_char_counter
$line_char_counter\n";
- if ($chomped_text ne '' and $line_char_counter < $indent_length)
- {
-print STDERR " indent_length $indent_length\n";
- $text_added = ' ' x ($indent_length -
$line_char_counter).$text_added;
- }
- $line_char_counter += length($text_added);
- }
- else
- {
- $line_char_counter += length($text_added);
- }
- new_text:
-print STDERR "ADDING `$text_added'\n" if ($text_added ne '');
- if ($text_added ne '')
- {
- if ($item_pending and !$item_line_added)
- {
- info_default_skip_spaces($current, $index, $close);
- $item_pending = undef;
- }
- }
- #Â from here, the next cmmand is available
- ($current, $index, $close) = info_default_iterator_next($current,
$index, $close);
-
- if ($text_added =~ /\S/)
- {
- $in_table_item = 0 if ($in_table_item);
- $info_state->{'blank_line'} = 0;
- }
- my ($line_passed, $end_of_line, $last_line, $text_indented, $blank_line)
= info_default_count_lines($text_added, $indent_length, ($indentation_done
- or $info_state->{'align_stack'}->[-1]->{'command'} eq 'center'
- or $info_state->{'align_stack'}->[-1]->{'command'} eq 'flushright'));
- $info_state->{'blank_line'} = 1 if ($blank_line);
- #Â only_space is set in all the conditionals
- if ($end_of_line)
- {
- $line_char_counter = 0;
- $in_exdent-- if ($in_exdent);
- if ($table_item_line)
- {
- $table_item_line--;
- $in_table_item = 1;
- }
- $info_state->{'blank_line'} = 1 if ($info_state->{'only_spaces'} and
($last_line !~ /\S/));
- $info_state->{'only_spaces'} = 1;
- }
- else
- {
- if ($line_passed)
- {# in that case we added more than one line, the $line_char_counter
- #Â is reset to the last line length.
- $line_char_counter = length($last_line);
- $in_exdent = 0;
- if ($last_line !~ /\S/)
- {
- $info_state->{'only_spaces'} = 1;
- }
- else
- {
- $info_state->{'only_spaces'} = 0;
- }
- }
- else
- {
- $info_state->{'only_spaces'} = 0 if ($last_line =~ /\S/);
- }
- }
- if ($info_state->{'align_stack'}->[-1]->{'command'} eq 'center'
- or $info_state->{'align_stack'}->[-1]->{'command'} eq 'flushright')
- {
- if (defined($current_line))
- {
- $text_added = $current_line . $text_added;
- }
- $text_indented = '';
- $current_line = undef;
- my $length_prepended = undef;
- foreach my $line (split /^/, $text_added)
- {
- my $chomped_line = $line;
- if (chomp($chomped_line))
- {
- $line =~ s/^\s*//;
- $line =~ s/\s*$//;
-
- if (length($line) eq 0)
- {
- $length_prepended = 0;
- $text_indented .= "\n";
- }
- else
- {
- if (length($line) > $max_column)
- {
- $length_prepended = 0;
- }
- elsif ($info_state->{'align_stack'}->[-1]->{'command'} eq
'center')
- {
- $length_prepended = (($max_column -1 - length($line))
/2);
- }
- else
- {
- $length_prepended = ($max_column -1 - length($line));
- }
- $text_indented .= ' ' x$length_prepended . $line ."\n";
- }
- }
- else
- {
- $current_line = $line;
- }
- }
- if (defined ($length_prepended) and
defined($info_state->{'align_stack'}->[-1]->{'anchors'}))
- {
- while (@{$info_state->{'align_stack'}->[-1]->{'anchors'}})
- {
- my $anchor = shift
@{$info_state->{'align_stack'}->[-1]->{'anchors'}};
- $anchor->{'info_offset'} += $length_prepended;
- }
- }
- }
-
- if ($direntry)
- {
- $info_default_dir_specification .= $text_indented;
- }
- else
- {
- $result .= $text_indented;
- $length += length($text_indented);
- $all_line_passed += $line_passed;
- }
- }
- return ($length, $result, $all_line_passed);
-}
-
-sub info_default_open_command($$;$)
-{
- my $state = shift;
- my $command = shift;
- my $additional_entries = shift;
-
- my $index = 0;
-
- my $info_state = info_default_get_state($state);
- #Â index in the parent content list
- $index = scalar(@{$info_state->{'current'}->{'content'}})
- if (defined($info_state->{'current'}->{'content'}));
- my $new_command = {'command' => $command, 'parent' =>
$info_state->{'current'}, 'index_in_parent' => $index };
- if (defined($additional_entries))
- {
- foreach my $key (keys(%$additional_entries))
- {
- $new_command->{$key} = $additional_entries->{$key};
- }
- }
-
- push @{$info_state->{'current'}->{'content'}}, $new_command;
- $info_state->{'current'} = $new_command;
- print STDERR "Opened $command ".
- "\n";
-}
-
-sub info_default_close_command($$;$$$)
-{
- my $state = shift;
- my $command = shift;
- my $begin = shift;
- my $end = shift;
- my $command_entries = shift;
-
- $state = $Texi2HTML::THISDOC{'state'} if (!defined($state));
- my $info_state = info_default_get_state($state);
- print STDERR "Closing $command ".
- "\n";
- if (!defined($info_state->{'current'}))
- {
- print STDERR "info_state->{'current'} not defined\n";
- }
- elsif (!defined($info_state->{'current'}->{'command'}))
- {
- print STDERR "info_state->{'current'}->{'command'} not defined\n";
- }
- elsif ($command ne $info_state->{'current'}->{'command'})
- {
- print STDERR "Was waiting for $info_state->{'current'}->{'command'}\n";
- }
- #return if $no_close;
- $command_entries->{'begin'} = $begin;
- $command_entries->{'end'} = $end;
- foreach my $key (keys(%$command_entries))
- {
- $info_state->{'current'}->{$key} = $command_entries->{$key}
- if (defined($command_entries->{$key}));
- }
-
- $info_state->{'current'} = $info_state->{'current'}->{'parent'};
-
- return info_default_output($info_state)
- if (!defined($info_state->{'current'}->{'command'}));
- return '';
-}
-
-sub info_default_store_text($$;$$)
-{
- my $state = shift;
- my $text = shift;
- my $command = shift;
- my $text_entries = shift;
-
- $state = $Texi2HTML::THISDOC{'state'} if (!defined($state));
- my $info_state = info_default_get_state($state);
- return '' if ((!defined($text) or $text eq '') and !defined($command));
-
- my $command_text = '';
- $command_text = "\[$command\]" if (defined($command));
- $command_text .= $text if (defined($text));
- print STDERR "Storing text ${command_text}\n";
-
- $text_entries->{'text'} = $text if (defined($text));
- $text_entries->{'command'} = $command if (defined($command));
- $text_entries->{'parent'} = $info_state->{'current'};
- push @{$info_state->{'current'}->{'content'}}, $text_entries;
- return info_default_output($info_state)
- if (!defined($info_state->{'current'}->{'command'}));
- return '';
-}
-
-sub info_default_begin_format_texi($$$)
-{
- my $command = shift;
- my $line = shift;
- my $state = shift;
-
- my $info_state = info_default_get_state ($state);
- my ($parent_format, $in_format);
- ($parent_format, $in_format) =
info_default_parent_format($info_state->{'current'});
- $info_state->{'paragraph_in_element_nr'}++ if (!$in_format);
-
- $parent_format->{'paragraph_in_element_nr'} = 0 if
(!defined($parent_format->{'paragraph_in_element_nr'}));
- $parent_format->{'paragraph_in_element_nr'}++;
-
- info_default_open_command($state,$command) unless ($def_map{$command} and
$command =~ /x$/);
- return $line;
-}
-
-sub info_default_begin_style_texi($$$$)
-{
- my $command = shift;
- my $state = shift;
- my $stack = shift;
- my $real_style_command = shift;
- info_default_open_command($state,$command)
- unless ($info_default_accent_commands{$command} or exists
$things_map{$command});
-# if ($real_style_command);
-}
-
-sub info_default_begin_paragraph_texi($$$)
-{
- my $command = shift;
- my $paragraph_macros = shift;
- my $paragraph_command = shift;
- #print STDERR "begin_paragraph $command\n";
- my $state = shift;
- my $stack = shift;
- #my $info_state = info_default_get_state($state);
- info_default_open_command($state,$command);
- foreach my $style_command (@$paragraph_macros)
- {
- print STDERR "para stack: $style_command->{'style'}\n";
- info_default_open_command($state,$style_command->{'style'});
- #$info_state->{'current'}->{'no_open'} = 1;
- }
-}
-
-sub info_default_simple_command($$$$)
-{
- my $command = shift;
- my $in_preformatted = shift;
- my $line_nr = shift;
- my $state = shift;
-
- my $result = $simple_map{$command};
- #Â discards '-' '|' '/' and ':'. If ':' is associated with a punctuation
- #Â character it is added to the tree in info_default_colon_command
- return info_default_store_text($state,$result,$command) if ($result ne '');
- return '';
- #return '' if info_default_store_text($state,$result,$command);
- #return $result;
-}
-
-sub info_default_colon_command($)
-{
- my $punctuation_character = shift;
- if (defined($colon_command_punctuation_characters{$punctuation_character})
- and $punctuation_character =~ /^[$punctuation_characters]$/)
- {
- return
info_default_store_text(undef,$colon_command_punctuation_characters{$punctuation_character},
':');
- }
- else
- {
- return info_default_store_text(undef,$punctuation_character);;
- }
-}
-
-sub info_default_thing_command($$$$$)
-{
- my $command = shift;
- my $text = shift;
- my $in_preformatted = shift;
- my $line_nr = shift;
- my $state = shift;
-
- my $result = $things_map{$command};
- #return info_default_close_command($state, $command, $result, $text, '');
- return info_default_store_text($state, $result, $command);
-# return $result . $text;
-}
-
-
-sub info_default_style($$$$$$$$$)
-{
- my $style = shift;
- my $command = shift;
- my $text = shift;
- my $args = shift;
- my $no_close = shift;
- my $no_open = shift;
- my $line_nr = shift;
- my $state = shift;
- my $command_stack = shift;
-
- my $begin = '';
- my $end = '';
-
- #Â note that the $text is always discarded for closed commands
-
- #Â the formatting is done right here, without information on the current
- #Â state, and the result is entered as text below.
- if ($info_default_leaf_command{$command})
- {
- my $style_index = 0;
- my @formatted_args = ();
- foreach my $arg (@$args)
- {
- my $arg_style = $style->{'orig_args'}->[$style_index];
- if ($arg_style eq 'normal')
- {
- push @formatted_args, main::substitute_line($arg,
"address@hidden");
- }
- elsif ($arg_style eq 'code')
- {
- push @formatted_args, main::substitute_line($arg,
"address@hidden", {'code_style' => 1});
- }
- else
- {
- print STDERR "Unknown arg style($style_index) $arg_style for
$command\n";
- }
- $style_index++;
- }
- $args = address@hidden;
- }
- if (defined($style->{'function'}))
- {
- $text = &{$style->{'function'}}($command, $args, $command_stack, $state,
$line_nr);
- }
- if (defined($style->{'begin'}) and !$no_open)
- {
- $begin = $style->{'begin'};
- }
- if (defined($style->{'end'}) and !$no_close)
- {
- $end = $style->{'end'};
- }
- unless($special_style{$command} or ($command eq 'cmd_line') or
$info_default_accent_commands{$command} or ($command eq 'hyphenation') or
$info_default_leaf_command{$command})
- {
- return info_default_close_command($state, $command, $begin, $end);
- }
- #Â this is for *ref, images and footnotes text registering and putting
- #Â in the tree.
- #Â anchor is already in the tree, from anchor_label.
- if (($special_style{$command} or $info_default_leaf_command{$command}) and
$command ne 'anchor')
- {
- return info_default_store_text ($state, $begin.$text.$end, $command);
- }
- #Â we go here for cmd_line, and also for accents, hyphenation and anchor
- #Â (though the result for anchor is always an empty string).
- return $begin.$text.$end;
-}
-
-sub info_default_header ()
-{
- return $Texi2HTML::THISDOC{'info_header'} if
(defined($Texi2HTML::THISDOC{'info_header'}));
- #my $result = "This is $setfilename, produced by
$Texi2HTML::THISDOC{program} from $Texi2HTML::THISDOC{'input_file_name'}.\n\n";
- #Â the following is wrong, $Texi2HTML::THISDOC{'input_file_name'}
- #Â should be used
- #Â directly, but then tests are not reproducible in out of source builds
- my $basename = $Texi2HTML::THISDOC{'input_file_name'};
- $basename =~ s/^.*\/// if ($TEST);
- $basename = $STDIN_DOCU_NAME if ($basename eq '-');
- my $result = "This is $Texi2HTML::THISDOC{'filename'}->{'top'}, produced
by makeinfo version 4.13 from $basename. ";
- my $dummy;
- ($dummy, $dummy, $dummy, $dummy, $result) =
info_default_process_text($result, 0, '', undef, undef, 1,
get_conf('fillcolumn'));
- $result .= "\n\n";
- $result .= "$Texi2HTML::THISDOC{'copying_comment'}";
- if ($info_default_dir_specification)
- {
- $result .= "$info_default_dir_specification\n";
- }
- $Texi2HTML::THISDOC{'info_header'} = $result;
- return $result;
-}
-
-sub info_default_print_page_head($)
-{
- my $fh = shift;
- my $header = info_default_header();
- print $fh "".$header;
-
- my $state = $Texi2HTML::THISDOC{'state'};
- my $info_state = info_default_get_state ($state);
- $info_state->{'offset_in_file'} += length($header);
- $info_state->{'blank_line'} = 1 if ($Texi2HTML::THISDOC{'copying_comment'}
eq '');
-}
-
-sub info_default_parent_format($)
-{
- my $parent_format = shift;
- my $in_format = 0;
- while (1)
- {
- if (defined($parent_format->{'command'}) and
$info_default_format{$parent_format->{'command'}})
- {
- $in_format = 1;
- last;
- }
- last if (!defined($parent_format->{'parent'}));
- $parent_format = $parent_format->{'parent'};
- }
- return ($parent_format, $in_format);
-}
-
-sub info_default_paragraph($$$$$$$$$$$$)
-{
- my $text = shift;
- my $align = shift;
- my $indent = shift;
- my $paragraph_command = shift;
- my $paragraph_command_formatted = shift;
- my $paragraph_number = shift;
- my $format = shift;
- my $item_nr = shift;
- my $enumerate_style = shift;
- my $number = shift;
- my $command_stack_at_end = shift;
- my $command_stack_at_begin = shift;
-
- my $top_stack = '';
- $top_stack = $command_stack_at_begin->[-1] if (scalar
(@$command_stack_at_begin));
-
- my $state = $Texi2HTML::THISDOC{'state'};
- my $info_state = info_default_get_state ($state);
- my ($parent_format, $in_format);
- ($parent_format, $in_format) =
info_default_parent_format($info_state->{'current'}->{'parent'});
- $parent_format->{'paragraph_in_format_nr'} = 0 if
(!defined($parent_format->{'paragraph_in_format_nr'}));
- $parent_format->{'paragraph_in_format_nr'}++;
-
- $info_state->{'paragraph_in_element_nr'}++ if (!$in_format);
- my $additional_args = {'top_stack' => $top_stack, 'parent_format' =>
$parent_format};
- $additional_args->{'paragraph_in_element_nr'} =
($info_state->{'paragraph_in_element_nr'} - 1) if (!$in_format);
-
- return info_default_close_command(undef, 'paragraph', undef, undef,
$additional_args);
-}
-
-# currently not used, but could be used if info_default_preformatted
-#Â return something that is not 'false', for example spaces, though we
-#Â want the preformatted to be ignored. Though it is not sure that if there
-#Â are spaces we want to ignore the preformatted.
-sub info_default_empty_preformatted($)
-{
- my $text = shift;
- my $result = info_default_preformatted($text, undef, undef, undef, undef,
- undef, undef, undef, undef);
- return 0;
-}
-
-sub info_default_preformatted($$$$$$$$$$$$)
-{
- my $text = shift;
- my $pre_style = shift;
- my $class = shift;
- my $leading_command = shift;
- my $leading_command_formatted = shift;
- my $preformatted_number = shift;
- my $format = shift;
- my $item_nr = shift;
- my $enumerate_style = shift;
- my $number = shift;
- my $command_stack_at_end = shift;
- my $command_stack_at_begin = shift;
-
- return info_default_close_command(undef, 'preformatted');
-}
-
-
-sub info_default_node_line($$)
-{
- my $element = shift;
- my $info_state = shift;
- my $outfile = $Texi2HTML::THISDOC{'filename'}->{'top'};
- $outfile = $STDOUT_DOCU_NAME if ($outfile eq '-');
- my $result = "\x{1F}\nFile: $outfile, Node: $element->{'text'}";
- if (defined($element->{'NodeNext'}))
- {
- $result .= ','.&$I(' Next: %{node_next}', {'node_next' =>
$element->{'NodeNext'}->{'text'}});
- }
- if (defined($element->{'NodePrev'}))
- {
- $result .= ','.&$I(' Prev: %{node_prev}', {'node_prev' =>
$element->{'NodePrev'}->{'text'}});
- }
- if (defined($element->{'NodeUp'}))
- {
- $result .= ','.&$I(' Up: %{node_up}', {'node_up' =>
$element->{'NodeUp'}->{'text'}});
- }
- $result .= "\n\n";
- $info_state->{'line_count'} = 3;
- $info_state->{'offset_in_file'} += length($result);
- $info_state->{'blank_line'} = 1;
- return $result;
-}
-
-sub info_default_element_heading($$$$$$$$$$$$)
-{
- my $element = shift;
- my $command = shift;
- my $texi_line = shift;
- my $line = shift;
- my $in_preformatted = shift;
- my $one_section = shift;
- my $element_heading = shift;
- my $first_in_page = shift;
- my $is_top = shift;
- my $previous_is_top = shift;
- my $command_line = shift;
- my $element_id = shift;
- my $new_element = shift;
-
- my $state = $Texi2HTML::THISDOC{'state'};
- my $info_state = info_default_get_state ($state);
-
- #Â FIXME use $element or $Texi2HTML::THIS_ELEMENT? Main program should
- #Â ensure they are the same.
- if ($new_element and ($element ne $new_element or !$element->{'node'}))
- {
- die "There is a new element, but element $element->{'texi'} is not a
node or not the new element\n";
- }
- return &$heading($element, $command, $texi_line, $line, $in_preformatted,
$one_section, $element_heading) unless ($new_element);
-
-print STDERR "HHHHHHHHHHHHHHH node($element->{'texi'}) $info_state->{'nr'}\n";
- my $before = '';
- $element->{'info_offset'} = $info_state->{'offset_in_file'};
- push @{$info_state->{'pending_tags'}}, $element;
-
- my $result = info_default_node_line($element, $info_state);
-
- $info_default_footnote_index = 0;
- $info_default_current_node = $element;
-
- return $before.$result;
-}
-
-sub info_default_heading($$$$$;$$)
-{
- my $element = shift;
- my $command = shift;
- my $texi_line = shift;
- my $line = shift;
- my $in_preformatted = shift;
- my $one_section = shift;
- my $element_heading = shift;
-
- die "Heading called for a node\n" if ($element->{'node'});
- my $state = $Texi2HTML::THISDOC{'state'};
- my $info_state = info_default_get_state ($state);
-print STDERR "HHHHHHHHHHHHHHH section($element->{'texi'})
$info_state->{'nr'}\n";
- $info_state->{'paragraph_in_element_nr'} = 0;
- my $text = "$element->{'text'}";
- #Â to do the same than makeinfo a trailing dot in section number is removed
- $text =~ s/^(\w+)\. /$1 /;
- #Â when @top is empty, use settitle
- $text = $Texi2HTML::THISDOC{'settitle'} if (!length($text) and
$element->{'tag'} eq 'top' and defined ($Texi2HTML::THISDOC{'settitle'}) and
length($Texi2HTML::THISDOC{'settitle'}));
- $text = "Annexe $text" if ($element->{'tag'} =~ /appendix/ and
$element->{'level'} <= 1);
- my $result = $text . "\n" .
- ($default_info_level_to_symbol{$element->{'level'}} x length($text)) .
"\n";
-
- $result .= "\n";
-
- return info_default_store_text($state, $result, $command,
{'heading_command' => 1});
-}
-
-sub info_default_normal_text($$$$$$;$)
-{
- my @initial_args = @_;
- my $text = shift;
- my $in_raw_text = shift; # remove_texi
- my $in_preformatted = shift;
- my $in_code = shift;
- my $in_simple = shift;
- my $style_stack = shift;
- my $state = shift;
-
- #Â $Texi2HTML::THISDOC{'ENCODING_NAME'}) should be defined, but maybe
- # not when parsing commands in first or second pass, and removeing texi
- #Â like what is done for @setfilename.
- if ($ENABLE_ENCODING and !$ENABLE_ENCODING_USE_ENTITY and
defined($Texi2HTML::THISDOC{'ENCODING_NAME'}) and
($Texi2HTML::THISDOC{'ENCODING_NAME'} eq 'utf-8'))
- {
- $text = &t2h_utf8_normal_text(@initial_args);
- }
- else
- {
-#print STDERR "info_default_normal_text $text $in_preformatted $in_code \n";
- $text = uc($text) if (in_cmd($style_stack, 'sc'));
- $text = uc($text) if (in_cmd($style_stack, 'var'));
-# $text = &$protect_text($text) unless($in_raw_text);
- if (! $in_code and !$in_preformatted)
- {
- $text =~ s/---/\x{1F}/g;
- $text =~ s/--/-/g;
- $text =~ s/\x{1F}/--/g;
- $text =~ s/``/"/g;
- $text =~ s/\'\'/"/g;
- }
- else
- {
- # to be like texinfo
-# my $special_code = 0;
-# $special_code = 1 if (in_cmd($style_stack, 'code') or
-# in_cmd($style_stack, 'example') or in_cmd($style_stack,
'verbatim'));
-# $text =~ s/'/\&rsquo\;/g unless ($special_code and
exists($main::value{'txicodequoteundirected'}));
-# $text =~ s/`/\&lsquo\;/g unless ($special_code and
exists($main::value{'txicodequotebacktick'}));
- }
- }
- #Â accented characters are not handled as text, but when the last
- #Â accent command on the stack is closed.
- if ($style_stack and @$style_stack and
$info_default_accent_commands{$style_stack->[-1]})
- {
- return $text;
- }
- return info_default_store_text($state,$text);
- #Â We never store in the stack text in raw text (remove_texi).
-# unless ($in_raw_text)
-# {
-# return '' if (info_default_store_text($state,$text));
-# }
-# return $text;
-}
-
-#Â this is not called in preformatted
-sub info_default_empty_line($$)
-{
- my $text = shift;
- my $state = shift;
- #ignore the line if it just follows a deff
- #return '' if ($state->{'deff_line'});
- return info_default_store_text($state,$text);
-# return '';
-}
-
-#Â change interface?
-sub info_default_anchor_label($$$)
-{
- my $id = shift;
- my $anchor_text = shift;
- my $anchor_reference = shift;
- print STDERR "Storing anchor $anchor_reference->{'text'}\n";
- return info_default_store_text(undef,undef,'anchor',{'anchor_reference' =>
$anchor_reference});
-}
-
-sub info_default_acronym_like($$$$$$)
-{
- my $command = shift;
- my $acronym_texi = shift;
- my $acronym_text = shift;
- my $with_explanation = shift;
- my $explanation_lines = shift;
- my $explanation_text = shift;
- my $explanation_simply_formatted = shift;
-
- if ($with_explanation)
- {
- return "$acronym_text ($explanation_text)";
- }
- else
- {
- return "$acronym_text";
- }
-}
-
-
-sub info_default_print_page_foot($)
-{
- my $fh = shift;
- my $state = $Texi2HTML::THISDOC{'state'};
- my $info_state = info_default_get_state ($state);
- my $indirect = 0;
- return unless (defined ($info_state->{'pending_tags'}));
- $indirect = 1 if ($info_default_out_file_nr > 1);
- if ($indirect)
- {
- close ($Texi2HTML::THISDOC{'FH'});
- unless (rename
("$Texi2HTML::THISDOC{'destination_directory'}$Texi2HTML::THISDOC{'filename'}->{'top'}",
"$Texi2HTML::THISDOC{'destination_directory'}$Texi2HTML::THISDOC{'filename'}->{'top'}-1"))
- {
- warn "Rename
$Texi2HTML::THISDOC{'destination_directory'}$Texi2HTML::THISDOC{'filename'}->{'top'}
failed: $!\n";
- }
- unless (open (INDIRECT,
">$Texi2HTML::THISDOC{'destination_directory'}$Texi2HTML::THISDOC{'filename'}->{'top'}"))
- {
- warn "Open
$Texi2HTML::THISDOC{'destination_directory'}$Texi2HTML::THISDOC{'filename'}->{'top'}
failed: $!\n";
- }
- print INDIRECT "".info_default_header();
- print INDIRECT "\x{1F}\nIndirect:";
- foreach my $indirect (@info_default_pending_indirect)
- {
- print INDIRECT "\n$indirect->{'file'}: $indirect->{'offset'}";
- }
- $fh = \*INDIRECT;
- }
- #Â makeinfo seems to add systematically an additional \n, done just below
- print $fh "\n\x{1F}\nTag Table:\n";
-
- if ($indirect)
- {
- print $fh "(Indirect)\n";
- }
- foreach my $element (@{$info_state->{'pending_tags'}})
- {
- my $prefix;
- $prefix = 'Node' if ($element->{'node'});
- $prefix = 'Ref' if ($element->{'anchor'} or $element->{'float'});
- print $fh "$prefix: $element->{'text'}\x{7F}$element->{'info_offset'}\n";
- }
- print $fh "\x{1F}\nEnd Tag Table\n";
- if (defined($Texi2HTML::THISDOC{'DOCUMENT_ENCODING'}))
- {
- my $coding = $Texi2HTML::THISDOC{'DOCUMENT_ENCODING'};
- if ($coding =~ /^iso-/i)
- {
- $coding = lc($coding);
- }
- print $fh "\n\x{1F}\nLocal Variables:\ncoding: $coding\nEnd:\n";
- }
-}
-
-sub info_default_print_Top_footer($$$)
-{
- my $fh = shift;
- my $end_page = shift;
- my $element = shift;
- if ($end_page)
- {
- &$print_page_foot($fh);
- }
- info_default_end_section($fh, $end_page, $element);
-}
-
-sub info_default_footnote_texi($$$)
-{
- my $text = shift;
- my $state = shift;
- my $style_stack = shift;
-
- $info_default_footnote_index++;
- return "($info_default_footnote_index) $text";
-}
-
-sub info_default_print_section
-{
- my $fh = shift;
- my $first_in_page = shift;
- my $previous_is_top = shift;
- my $element = shift;
- my $nw = main::print_lines($fh);
- my $state = $Texi2HTML::THISDOC{'state'};
- my $info_state = info_default_get_state ($state);
- if (!$info_state->{'blank_line'})
- {
- my $end = "\n";
- $info_state->{'offset_in_file'} += length($end);
- $info_state->{'line_count'}++;
- print $fh "$end";
- }
- if (@info_default_pending_footnotes)
- {
- my $footnote_text;
- my $footnote_element;
- if (get_conf('footnotestyle') eq 'separate')
- {
- my $node_ref = $info_default_current_node;
- $node_ref = {'text' => 'no node', 'file' => ''} if
(!defined($node_ref));
- $footnote_element = { 'NodeUp' => $node_ref,
- 'text' => $node_ref->{'text'} . "-Footnotes",
- 'file' => $node_ref->{'file'},
- 'info_offset' => $info_state->{'offset_in_file'},
- 'node' => 1
- };
- push @{$info_state->{'pending_tags'}}, $footnote_element;
- $footnote_text = info_default_node_line($footnote_element,
$info_state);
- }
- else
- {
- $footnote_text = " ---------- Footnotes ----------\n\n";
- $info_state->{'offset_in_file'} += length($footnote_text);
- $info_state->{'line_count'} += 2;
-print STDERR "MMMMMMMMMMMMMMMMMM $info_state->{'line_count'}\n";
- }
- while (@info_default_pending_footnotes)
- {
- #push @info_default_pending_footnotes, [$lines, $footnote_text,
${info_default_footnote_index}, $node_name, $footnote_info_state];
- my $footnote = shift @info_default_pending_footnotes;
- my $foot_nr = $footnote->{'footnote_index'};
- my $node_name = $footnote->{'node_name'};
- my $lines = $footnote->{'lines'};
- push @{$info_state->{'pending_tags'}}, {'anchor' => 1, 'text' =>
"${node_name}-Footnote-${foot_nr}", 'info_offset' =>
$info_state->{'offset_in_file'} };
- my $footnote_info_state = $footnote->{'footnote_info_state'};
- my $footnote_result = shift @{$lines};
- my $initial_length = length($footnote_result);
-
- $footnote_result =~ s/^\s*//;
- #$footnote_result = " ($foot_nr) " . $footnote_result;
- $footnote_result = ' ' x get_conf('paragraphindent') .
$footnote_result;
- foreach my
$footnote_pending_tags(@{$footnote_info_state->{'pending_tags'}})
- {
- $footnote_pending_tags->{'info_offset'} +=
$info_state->{'offset_in_file'} + length($footnote_result) - $initial_length;
- push @{$info_state->{'pending_tags'}}, $footnote_pending_tags;
- }
- foreach my
$footnote_pending_index_entry(@{$footnote_info_state->{'pending_index_entries'}})
- {
-print STDERR
"TTTTTTTTTTT($footnote_pending_index_entry->{'index_entry_reference'}->{'entry'})
$footnote_pending_index_entry->{'line_nr'} $info_state->{'line_count'}\n";
- $footnote_pending_index_entry->{'line_nr'} +=
$info_state->{'line_count'};
-
$footnote_pending_index_entry->{'index_entry_reference'}->{'real_element'} =
$footnote_element if (get_conf('footnotestyle') eq 'separate');
- }
- my $line;
- while (@$lines)
- {
- $line = shift @$lines;
- $footnote_result .= $line;
- }
- my ($line_passed, $end_of_line, $last_line, $text_indented,
$blank_line) = info_default_count_lines($footnote_result);
- if ($line_passed == 0)
- {#Â certainly out of paragraph commands
- $footnote_result =~ s/\s*$//;
- $footnote_result .= "\n";
- $line_passed = 1;
- }
- unless (($last_line !~ /\S/ and $end_of_line) or ($blank_line))
- {
- $footnote_result .= "\n";
- $line_passed += 1;
- }
-
- $info_state->{'offset_in_file'} += length($footnote_result);
- $info_state->{'line_count'} += $line_passed;
- $footnote_text .= $footnote_result;
- }
- print $fh "$footnote_text";
- }
-}
-
-sub info_default_end_section($$$)
-{
- my $fh = shift;
- my $end_foot_navigation = shift;
- my $element = shift;
- my $state = $Texi2HTML::THISDOC{'state'};
- my $info_state = info_default_get_state ($state);
-
- if (defined($Texi2HTML::THISDOC{'SPLIT_SIZE'}) and
- $info_state->{'offset_in_file'} > ($info_default_out_file_nr) *
$Texi2HTML::THISDOC{'SPLIT_SIZE'})
- {
- if ($info_default_out_file_nr == 1)
- {
- push @info_default_pending_indirect,
{'file'=>"$Texi2HTML::THISDOC{'filename'}->{'top'}-$info_default_out_file_nr",
'offset' => $info_state->{'pending_tags'}->[0]->{'info_offset'} };
- }
- $info_default_out_file_nr++;
- close($Texi2HTML::THISDOC{'FH'});
- if (!$end_foot_navigation)
- {
-
main::open_out_file("$Texi2HTML::THISDOC{'filename'}->{'top'}-$info_default_out_file_nr");
- print STDERR "X-$info_default_out_file_nr:
$info_state->{'offset_in_file'}\n";
- &$print_page_head($Texi2HTML::THISDOC{'FH'});
- push @info_default_pending_indirect,
{'file'=>"$Texi2HTML::THISDOC{'filename'}->{'top'}-$info_default_out_file_nr",
'offset' => $info_state->{'offset_in_file'}};
- }
- }
-}
-
-sub info_default_one_section($$)
-{
- my $fh = shift;
- my $element = shift;
- &$print_section($fh, 1, 0, $element);
- &$print_page_foot($fh);
-}
-
-sub info_default_begin_special_region($$$)
-{
- my $region = shift;
- my $state = shift;
- my $lines = shift;
- my $info_state = info_default_get_state ($state);
- #Â reset paragraph_in_element_nr if out ofdocument formatting
- if ($state->{'outside_document'})
- {
- $info_state->{'paragraph_in_element_nr'} = 0;
- }
-}
-
-sub info_default_end_special_region($$$)
-{
- my $region = shift;
- my $state = shift;
- my $text = shift;
- my $info_state = info_default_get_state ($state);
- my $end = '';
- if (!$info_state->{'blank_line'})
- {
- $end = "\n";
- $info_state->{'offset_in_file'} += length($end);
- }
- return $text.$end;
-}
-
-sub info_default_menu_link($$$$$$$$)
-{
- my $entry = shift;
- my $state = shift;
- my $href = shift;
- my $node = shift;
- my $title = shift;
- my $ending = shift;
- my $has_title = shift;
- my $command_stack = shift;
- my $preformatted = shift;
-
- $title = '' unless ($has_title);
- $title .= ':' if ($title ne '');
- my $result = "$MENU_SYMBOL$title$node$ending";
- return info_default_store_text($state,$result,'menu_entry');
-}
-
-#Â not used, menu is a normal preformatted command
-#sub info_default_menu_command($$$)
-#{
-# my $format = shift;
-# my $text = shift;
-# my $in_preformatted = shift;
-#print STDERR "MENU $format\n";
-# return info_default_close_command(undef, $format, "* Menu:\n", undef,
"\n");
-#}
-
-sub info_default_complex_format($$)
-{
- my $name = shift;
- my $text = shift;
- my ($begin, $end);
- if ($name eq 'menu')
- {
- $begin = "* Menu:\n\n";
- }
- elsif ($name eq 'direntry')
- {
- $begin = "START-INFO-DIR-ENTRY\n";
- $end = "END-INFO-DIR-ENTRY\n";
- }
- return info_default_close_command(undef, $name, $begin, $end);
-}
-
-sub info_default_quotation($$$$)
-{
- my $command = shift;
- my $text = shift;
- my $argument_text = shift;
- my $argument_text_texi = shift;
-
- return info_default_close_command(undef, $command);
-}
-
-sub info_default_misc_commands($$$$$)
-{
- my $command = shift;
- my $line = shift;
- my $pass = shift;
- my $stack = shift;
- my $state = shift;
-
- return ($line, 0, undef, undef) unless ($pass == 2);
- return ($line, 0, undef, undef) unless ($command eq 'exdent' or $command
eq 'noindent' or $command eq 'indent');
- my ($result_line, $text, $args) = &$preserve_misc_command ($line,
$command);
- info_default_store_text($state,'',$command);
- return ($result_line, 1, '', undef);
-}
-
-sub info_default_external_ref($$$$$$$$)
-{
- my $type = shift;
- my $section = shift;
- my $book = shift;
- my $file_node = shift;
- my $href = shift;
- my $cross_ref = shift;
- my $args_texi = shift;
- my $formatted_args = shift;
-
- return info_default_inforef($formatted_args) if ($type eq 'inforef');
- return info_default_normal_reference($type, $formatted_args);
-}
-
-sub info_default_internal_ref($$$$$$$$)
-{
- my $type = shift;
- my $href = shift;
- my $short_name = shift;
- my $name = shift;
- my $is_section = shift;
- my $args_texi = shift;
- my $formatted_args = shift;
- my $element = shift;
-
- $formatted_args->[1] = $name if ($element->{'float'} and
(!defined($formatted_args->[1]) or $formatted_args->[1] eq ''));
- return info_default_inforef($formatted_args) if ($type eq 'inforef');
- return info_default_normal_reference($type, $formatted_args);
-}
-
-sub info_default_normal_reference($$)
-{
- my $command = shift;
- my $formatted_args = shift;
- for (my $i = 0; $i < scalar(@$formatted_args); $i++)
- {
- $formatted_args->[$i] = undef if (defined($formatted_args->[$i]) and
- $formatted_args->[$i] =~ /^\s*$/);
- }
- my $node = $formatted_args->[0];
- my $name = $formatted_args->[1];
- $name = $formatted_args->[2] if (!defined($name));
- my $file = $formatted_args->[3];
- $file = '' if (!defined($file) and defined($formatted_args->[4]));
- $name = $node if (!defined($name) and defined($file));
- my $result = '*note ';
- $result = '*Note ' if ($command eq 'xref');
- if (defined($name))
- {
- $result .= "${name}: ";
- $result .= "($file)" if (defined($file));
- $result .= "$node";
- $result .= '.' if ($command eq 'pxref');
- }
- else
- {
- $result .= "${node}::";
- }
- return $result;
-}
-
-sub info_default_inforef($)
-{
- my $formatted_args = shift;
- return info_default_normal_reference('ref', [$formatted_args->[0],
$formatted_args->[1], undef, $formatted_args->[2], 'dumb manual name']);
-}
-
-sub info_default_image_files($$$$)
-{
- my $base = shift;
- my $extension = shift;
- my $texi_base = shift;
- my $texi_extension = shift;
- my @files = ();
- return @files if (!defined($base) or ($base eq ''));
-
- if (defined($extension) and ($extension ne ''))
- {
- push @files, ["${base}$extension", "${texi_base}$extension"];
- push @files, ["$base.$extension", "$texi_base.$extension"];
- }
- foreach my $ext (@IMAGE_EXTENSIONS)
- {
- push @files, ["$base.$ext", "$texi_base.$ext"];
- }
- return @files;
-}
-
-sub info_default_image($$$$$$$$$$$$$$$$$)
-{
- my $file = shift;
- my $base = shift;
- my $preformatted = shift;
- my $file_name = shift;
- my $alt = shift;
- my $width = shift;
- my $height = shift;
- my $raw_alt = shift;
- my $extension = shift;
- my $working_dir = shift;
- my $file_path = shift;
- my $in_paragraph = shift;
- my $file_locations = shift;
- my $base_simple_format = shift;
- my $extension_simple_format = shift;
- my $file_name_simple_format = shift;
- my $line_nr = shift;
-
- my $txt_path;
- my $found_file;
-
- my @extensions = @IMAGE_EXTENSIONS;
- if (defined($extension) and ($extension ne ''))
- {
- unshift @extensions, ".$extension";
- unshift @extensions, "$extension";
- }
- else
- {
- $extension = undef;
- }
- my $file_found_index = undef;
- my $file_index = 0;
- foreach my $file_location (@$file_locations)
- {
- my ($file_located, $path, $file_simple_format) = @$file_location;
- my $extension = shift @extensions;
- if (defined($path))
- {
- if ($extension eq 'txt' and !defined($txt_path))
- {
- $txt_path = $path;
- }
- elsif (!defined($found_file))
- {
- $found_file = [$file_located, $extension, $file_simple_format];
- $file_found_index = $file_index;
- }
- }
- $file_index++;
- }
-
- my $text;
- if (defined($txt_path))
- {
- if (open(TXT, "<$txt_path"))
- {
- if (defined($Texi2HTML::THISDOC{'IN_ENCODING'}) and $USE_UNICODE)
- {
- binmode(TXT, ":encoding($Texi2HTML::THISDOC{'IN_ENCODING'})");
- }
- $text='[' if ($in_paragraph or $preformatted);
- while (my $img_txt = <TXT>)
- {
- $text .= $img_txt;
- }
- $text .= ']' if ($in_paragraph or $preformatted);
- close(TXT);
- }
- else
- {
- main::echo_warn ("address@hidden file `$txt_path' unreadable: $!",
$line_nr);
- }
- }
- else
- {
- main::echo_warn ("Cannot find address@hidden file `$base.txt'",
$line_nr);
- }
- if (defined($found_file) and (!defined($extension) or $file_found_index <=
1))
- {
- my $filename = $found_file->[2];
- $filename =~ s/\\/\\\\/g;
- $filename =~ s/\"/\\\"/g;
- my $result = "\x{00}\x{08}[image src=\"$filename\"";
- if (defined($alt))
- {
- $alt =~ s/\\/\\\\/g;
- $alt =~ s/\"/\\\"/g;
- $result .= " alt=\"$alt\"";
- }
- if (defined($text))
- {
- $text =~ s/\\/\\\\/g;
- $text =~ s/\"/\\\"/g;
- $result .= " text=\"$text\"";
- }
- $result .= "\x{00}\x{08}]";
- return $result;
- }
- return $text if (defined($text));
- return '';
-}
-
-sub info_default_print_index($$)
-{
- my $text = shift;
- my $name = shift;
- my $state = $Texi2HTML::THISDOC{'state'};
- my $info_state = info_default_get_state ($state);
- my $before = '';
- if (!$info_state->{'blank_line'})
- {
- $before = "\n";
- $info_state->{'offset_in_file'} += length($before);
- $info_state->{'line_count'}++;
- $info_state->{'blank_line'} = 1;
- }
- return $before if (!defined($text));
- my $result = "\x{00}\x{08}[index\x{00}\x{08}]\n* Menu:\n\n" .$text."\n";
- $info_state->{'offset_in_file'} += length($result);
-
- my ($line_passed, $end_of_line, $last_line, $text_indented, $blank_line) =
info_default_count_lines($result);
- $info_state->{'blank_line'} = 1 if (($last_line !~ /\S/ and $end_of_line)
or ($blank_line));
- $info_state->{'line_count'} += $line_passed;
- return $before.$result;
-}
-
-sub info_default_index_letter($$$)
-{
- my $letter = shift;
- my $id = shift;
- my $text = shift;
- return $text;
-}
-
-sub info_default_index_entry_label($$$$$$$$)
-{
- my $identifier = shift;
- my $preformatted = shift;
- my $entry = shift;
- my $index_name = shift;
- my $index_command = shift;
- my $texi_entry = shift;
- my $formatted_entry = shift;
- my $index_entry_ref = shift;
-
- my $state = $Texi2HTML::THISDOC{'state'};
- my $info_state = info_default_get_state($state);
- print STDERR "Storing index entry $formatted_entry\n";
- my $index_entry_stored = {'command' => 'index_label',
'index_entry_reference' => $index_entry_ref, 'index_command' => $index_command,
'index_name' => $index_name};
- push @{$info_state->{'current'}->{'content'}}, $index_entry_stored;
- return info_default_output($info_state)
- if (!defined($info_state->{'current'}->{'command'}));
- return '';
-}
-
-sub info_default_index_entry($$$$$$$$)
-{
- my $text_href = shift;
- my $entry = shift;
- my $element_href = shift;
- my $element_text = shift;
- my $entry_file = shift;
- my $current_element_file = shift;
- my $entry_target = shift;
- my $entry_element_target = shift;
- my $index_entry_ref = shift;
-
- return '' if ($index_entry_ref->{'hidden'});
- $entry = main::substitute_line($index_entry_ref->{'texi'}, "index entry in
address@hidden");
-
- my $result = "* $entry: ";
- if (length($result) < $info_default_index_length_to_node)
- {
- $result .= ' ' x($info_default_index_length_to_node - length($result));
- }
- my $element = $index_entry_ref->{'real_element'};
- $element = $element->{'element_ref'} if ($element->{'element_ref'});
- $result .= $element->{'text'} . '.';
- my $info_index_entry_ref = $info_default_index_entries{$index_entry_ref};
- my $line_nr = $info_index_entry_ref->{'line_nr'};
- #Â this happens for index entries appearing after @printindex. In that case
- #Â it is consideered that they are at the beginning of the node.
- $line_nr = 4 if (!defined($line_nr) or $line_nr < 4);
- my $max_len =
$info_default_index_line_string_length{$info_index_entry_ref->{'index_name'}};
- my $line_nr_spaces = sprintf("%${max_len}d", $line_nr);
- my $line_part = "(line ${line_nr_spaces})";
-#print STDERR "GGGGGGGGGG name: $info_index_entry_ref->{'index_name'} max:
${max_len} line_nr: `$line_nr' line_nr_spaces `$line_nr_spaces' $line_part \n";
- if (length($result)+length($line_part) +1 > get_conf('fillcolumn'))
- {
- $result .= "\n" . ' ' x (get_conf('fillcolumn') - length($line_part)) ;
- }
- else
- {
- $result .= ' ' x (get_conf('fillcolumn') - length($line_part) -
length($result));
- }
- $result .= "$line_part\n";
-
- return $result;
-}
-
-sub info_default_index_summary($$)
-{
- my $alpha = shift;
- my $nonalpha = shift;
-
- return '';
-}
-
-sub info_default_summary_letter
-{
- return '';
-}
-
-sub info_default_foot_line_and_ref($$$$$$$$)
-{
- my $foot_num = shift;
- my $relative_num = shift;
- my $footid = shift;
- my $docid = shift;
- my $from_file = shift;
- my $footnote_file = shift;
- my $lines = shift;
- my $state = shift;
-
- my $footnote_state = $Texi2HTML::THISDOC{'state'};
- my $footnote_info_state = info_default_get_state ($footnote_state);
-
- my $footnote_text = "($info_default_footnote_index)";
- my $node_name;
- $node_name = '';
- $node_name = $info_default_current_node->{'text'} if
defined($info_default_current_node);
- if (get_conf('footnotestyle') eq 'separate')
- {
- $footnote_text .= ' (' . info_default_normal_reference('pxref',
["${node_name}-Footnote-${info_default_footnote_index}"]) . ')';
- }
- push @info_default_pending_footnotes, {'lines' => $lines,
- 'footnote_text' => $footnote_text,
- 'footnote_index' => ${info_default_footnote_index},
- 'node_name' => $node_name,
- 'footnote_info_state' => $footnote_info_state};
- return ($lines, $footnote_text);
-}
-
-sub info_default_foot_lines($)
-{
- my $lines = shift;
- #my $state = $Texi2HTML::THISDOC{'state'};
- #my $info_state = info_default_get_state ($state);
- @$lines = ();
-}
-
-#Â remark: table_item is the html one, but it gets added to the table text
-#Â on the stack, and is ignored there (in info_default_format).
-sub info_default_format_list_item_texi($$$$)
-{
- my $format = shift;
- my $line = shift;
- my $prepended = shift;
- my $command = shift;
- my $number = shift;
-
- my $open_command = 0;
- my $result_line;
- $command = 'bullet' if ((!defined($command) or $command eq '') and
(!defined($prepended) or $prepended eq '') and $format eq 'itemize');
- $prepended = "address@hidden" if (defined($command) and $command ne '');
- $prepended = "$number." if (defined($number) and $number ne '');
-
- if (defined($command) and $command ne '' and $format ne 'itemize')
- {
- address@hidden
- #info_default_begin_style_texi($command, $Texi2HTML::THISDOC{'state'},
undef, undef);
- #$open_command = 1;
- $line =~ s/^\s*//;
- $line =~ s/\s*$//;
- if (exists ($style_map{$command}))
- {
- $result_line = "address@hidden";
- }
- elsif (exists ($things_map{$command}))
- {
- $result_line = "address@hidden $line\n";
- }
- else
- {
- $result_line = "address@hidden $line\n";
- }
- }
- elsif (defined($prepended) and $prepended ne '')
- {
- $prepended =~ s/^\s*//;
- $prepended =~ s/\s*$//;
- $line =~ s/^\s*//;
- $result_line = $prepended . ' ' . $line;
- }
-
- return ($result_line, $open_command);
-}
-
-sub info_default_list_item($$$$$$$$$$$)
-{
- my $text = shift;
- my $format = shift;
- my $command = shift;
- my $formatted_command = shift;
- my $item_nr = shift;
- my $enumerate_style = shift;
- my $number = shift;
- my $prepended = shift;
- my $prepended_formatted = shift;
- my $only_inter_item_commands = shift;
- my $before_items = shift;
-
-# my $prepend = '';
-# if (defined($formatted_command) and $formatted_command ne '')
-# {
-# $prepend = $formatted_command;
-# }
-# return $prepend . $text;
- return $text;
-}
-
-sub info_default_format($$$)
-{
- my $tag = shift;
- my $element = shift;
- my $text = shift;
-
- # currently no command has something else than '' as $element.
- # notice that any text is discarded
- $element = undef if ($element eq '');
- my $element_end = $element;
- if (defined($element) and $element =~ /^(\w+)(\s+)(.+)/)
- {
- $element = $1;
- $element_end = $2;
- }
- return info_default_close_command(undef, $tag, $element, $element_end);
-}
-
-sub info_default_tab_item_texi($$$$$$)
-{
- my $command = shift;
- my $commands_stack = shift;
- my $stack = shift;
- my $state = shift;
- my $line = shift;
- my $line_nr = shift;
-
- my $format;
- $format = $commands_stack->[-1] if (defined($commands_stack) and
@$commands_stack and $commands_stack->[-1]);
-print STDERR "tab_item_texi $command $commands_stack, $stack, $state, $line,
$line_nr\n";
- if ($format eq 'multitable')
- {
- if ($command ne 'tab')
- {
- info_default_open_command($state, 'multitable_row');
- }
- info_default_open_command($state, 'multitable_cell');
- }
- else
- {
- info_default_store_text ($state, '', $command, {'format_name' =>
$format});
- }
- $line =~ s/^\s*//;
- return $line;
-}
-
-sub info_default_sp($$)
-{
- my $number = shift;
- my $preformatted = shift;
- my $result = "\n" x $number;
- return info_default_store_text(undef,$result,'sp');
-}
-
-sub info_default_paragraph_style_command($$)
-{
- my $format = shift;
- my $text = shift;
- return info_default_close_command(undef, $format);
-}
-
-sub info_default_row($$$$$$$$)
-{
- my $text = shift;
- my $macro = shift;
- my $columnfractions = shift;
- my $prototype_row = shift;
- my $prototype_lengths = shift;
- my $column_number = shift;
- my $only_inter_item_commands = shift;
- my $before_items = shift;
-
- return info_default_close_command(undef, 'multitable_row', undef, undef,
{'item_command' => $macro});
-}
-
-sub info_default_cell($$$$$$$$)
-{
- my $text = shift;
- my $row_macro = shift;
- my $columnfractions = shift;
- my $prototype_row = shift;
- my $prototype_lengths = shift;
- my $column_number = shift;
- my $only_inter_item_commands = shift;
- my $before_items = shift;
-
- return info_default_close_command(undef, 'multitable_cell');
-}
-
-sub info_default_table_list($$$$$$$$$)
-{
- my $format_command = shift;
- my $text = shift;
- my $command = shift;
- my $formatted_command = shift;
-# enumerate
- my $item_nr = shift;
- my $enumerate_style = shift;
-# itemize
- my $prepended = shift;
- my $prepended_formatted = shift;
-# multitable
- my $columnfractions = shift;
- my $prototype_row = shift;
- my $prototype_lengths = shift;
- my $column_number = shift;
-
- return info_default_close_command(undef, $command) if ($format_command ne
'multitable');
-
- my $columnsize = [];
- if (defined($prototype_lengths) and @$prototype_lengths)
- {
- $columnsize = [ @$prototype_lengths ];
- }
- elsif (defined($columnfractions) and @$columnfractions)
- {
- foreach my $fraction (@$columnfractions)
- {
- push @$columnsize, int($fraction * get_conf('fillcolumn') +0.5);
- }
- }
- else
- {
- print STDERR "Empty multitable?\n";
- }
-
- return info_default_close_command(undef, $format_command, undef, undef,
{'columns_size' => $columnsize});
-}
-
-sub info_default_def_item($$$)
-{
- my $text = shift;
- my $only_inter_item_commands = shift;
- my $command = shift;
-
- my $format = 'deff_item';
- $format = 'deff_itemx' if ($command =~ /x$/);
- print STDERR "LLLLLLLLLLLLLL $format $command\n";
- return info_default_close_command(undef, $format);
-}
-
-sub info_default_def_line($$$$$$$$$$$$$$$$)
-{
- my $category_prepared = shift;
- my $name = shift;
- my $type = shift;
- my $arguments = shift;
- my $index_label = shift;
- my $arguments_array = shift;
- my $arguments_type_array = shift;
- my $unformatted_arguments_array = shift;
- my $command = shift;
- my $class_name = shift;
- my $category = shift;
- my $class = shift;
- my $style = shift;
- my $original_command = shift;
-
- $name = '' if (!defined($name) or ($name =~ /^\s*$/));
- $type = '' if (!defined($type) or $type =~ /^\s*$/);
- $arguments = '' if (!defined($arguments) or $arguments =~ /^\s*$/);
-
- my $type_name = '';
- $type_name .= "$type " if ($type ne '');
- $type_name .= $name if ($name ne '');
-
- my $result = " -- $category_prepared: ${type_name}$arguments";
- $result =~ s/\s*$//;
- $result .= "\n";
- my $state = $Texi2HTML::THISDOC{'state'};
-# if ($command =~ /x$/)
-# {
- info_default_store_text(undef,$result,"${command}_line",{'definition_line'
=> 1});
-# }
-# else
-# {
-# return info_default_open_command($state, $command, {'begin'=>$result});
-# }
- my $format = 'deff_item';
- $format = 'deff_itemx' if ($original_command =~ /x$/);
- print STDERR "JJJJJJJJJJJJJ $command GGG $original_command $format\n";
- return info_default_open_command($state, $format);
-}
-
-sub info_default_def($$)
-{
- my $text = shift;
- my $command = shift;
- return info_default_close_command(undef, $command);
-}
-
-sub info_default_float($$$$$)
-{
- my $text = shift;
- my $float = shift;
- my $caption = shift;
- my $shortcaption = shift;
-
- my $additional_arguments;
- if (exists($float->{'id'}))
- {
- $additional_arguments->{'anchor_reference'} = $float;
- }
- my $caption_text = '';
-
- if (defined($float->{'caption_texi'}))
- {
- $caption_text = $caption;
- }
- elsif (defined($float->{'shortcaption_texi'}))
- {
- $caption_text = $shortcaption;
- }
- elsif (defined($caption))
- {
- $caption_text = $caption;
- }
-
- #return $caption_text;
- return info_default_close_command(undef, 'float', undef, $caption_text,
$additional_arguments);
-}
-
-sub info_default_listoffloats_entry($$$$)
-{
- my $style_texi = shift;
- my $float = shift;
- my $float_style = shift;
- my $caption = shift;
- my $href = shift;
-
- my @lines = split /^/, $caption;
- $caption = $lines[0];
- chomp ($caption);
-
- my $result = '';
- $caption .= ':' if ($caption ne '');
- my $caption_entry = "* $float_style: $caption";
- my $length = 0;
- while ($caption_entry =~ s/^(\S+\s*)//)
- {
-print STDERR "CAPTION_ENTRY($length) $caption_entry\n";
- my $new_word = $1;
- if (length($new_word) + $length >
($info_default_listoffloat_caption_entry_length - 3) or (length($new_word) +
$length + length($info_default_listoffloat_append) >
$info_default_listoffloat_caption_entry_length and $caption_entry ne ''))
- {
- $result .= $info_default_listoffloat_append;
- last;
- }
- else
- {
- $result .= $new_word;
- $length += length($new_word);
- }
- }
-print STDERR "RESULT `$result'\n";
- $result .= ' ' x ($info_default_listoffloat_caption_entry_length -
length($result));
-print STDERR "RESULT `$result'\n";
-
- return "${result}$float->{'text'}.\n";
-}
-
-sub info_default_listoffloats($$$)
-{
- my $style_texi = shift;
- my $style = shift;
- my $float_entries = shift;
-
- my $state = $Texi2HTML::THISDOC{'state'};
- my $info_state = info_default_get_state ($state);
- my $result = "* Menu:\n\n";
- foreach my $float_entry (@$float_entries)
- {
- $result .= $float_entry;
- }
- my ($parent_format, $in_format);
- ($parent_format, $in_format) =
info_default_parent_format($info_state->{'current'});
-#print STDERR "JJJJJJJJJJj listoffloats not in top\n" if ($in_format);
- $info_state->{'paragraph_in_element_nr'}++ if (!$in_format);
- return info_default_store_text($state,$result,'listoffloats');
-}
-
-sub info_default_raw($$)
-{
- my $style = shift;
- my $text = shift;
- my $expanded = 1 if (grep {$style eq $_} @EXPAND);
- if ($style eq 'verbatim' or $style eq 'verbatiminclude' or $expanded)
- {
- return info_default_store_text(undef,$text, $style);
- }
-# if ($style eq 'direntry')
-# {
-# $info_default_dir_specification .= "START-INFO-DIR-ENTRY\n"
-# .$text. "END-INFO-DIR-ENTRY\n";
-# }
- return '';
-}
-
-sub info_default_line_command($$$$)
-{
- my $command = shift;
- my $arg_text = shift;
- my $arg_texi = shift;
- my $state = shift;
-
- return '' if ($arg_text eq '');
- $info_default_dir_specification .= "INFO-DIR-SECTION $arg_text\n";
- return '';
-}
-
-#Â info is special, since it doesn't use the basename but directly the
-#Â setfilename output, contrary to all the other formats
-sub info_default_element_file_name($$$)
-{
- my $element = shift;
- my $type = shift;
- my $prefix = shift;
-
- my $outname;
- $outname = $OUT if (defined($OUT) and $OUT ne '' and $OUT !~ /\/$/ and
$Texi2HTML::THISDOC{'input_file_number'} == 0);
- if ($type eq 'doc')
- {
- if (defined($Texi2HTML::THISDOC{'setfilename'}) and !defined($outname))
- {
- $Texi2HTML::THISDOC{'extension'} = '';
- return $Texi2HTML::THISDOC{'setfilename'};
- }
- }
-
- return undef;
-}
-
-1;
Index: examples/xml.init
===================================================================
RCS file: examples/xml.init
diff -N examples/xml.init
--- examples/xml.init 17 May 2009 15:35:16 -0000 1.17
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,1219 +0,0 @@
-use strict;
-
-$EXTENSION = "xml";
-$DOCTYPE = '<!DOCTYPE texinfo PUBLIC "-//GNU//DTD TexinfoML V4.12//EN"
"http://www.gnu.org/software/texinfo/dtd/4.12/texinfo.dtd">';
-$USE_MENU_DIRECTIONS = 0;
-$USE_UP_FOR_ADJACENT_NODES = 0;
-$USE_NUMERIC_ENTITY = 0;
-$USE_SETFILENAME = 1;
-$SEPARATE_DESCRIPTION = 1;
-$USE_NODES = 1;
address@hidden = ('xml', 'direntry');
-
-$USE_ISO = 0;
-$SECTION_NAVIGATION = 0;
-
-push @Texi2HTML::Config::command_handler_process, \&xml_init_variables;
-
-$colon_command_punctuation_characters{'.'} = '.';
-$colon_command_punctuation_characters{':'} = ':';
-$colon_command_punctuation_characters{'?'} = '?';
-$colon_command_punctuation_characters{'!'} = '!';
-
-$simple_map{'*'} = '&linebreak;';
-$simple_map{' '} = '&space;';
-$simple_map{"\t"} = '&space;';
-$simple_map{"\n"} = '&space;';
-$simple_map{'.'} = '&eosperiod;';
-$simple_map{'!'} = '&eosexcl;';
-$simple_map{'?'} = '&eosquest;';
-
-%simple_map_pre = %simple_map;
-
-# FIXME right?
-$things_map{'l'} = '/l';
-$things_map{'L'} = '/L';
-$things_map{'enddots'} = '&enddots;';
-$things_map{'dots'} = '&dots;';
-# FIXME ≡
-#$things_map{'equiv'} = '==';
-$things_map{'minus'} = '−';
-$things_map{'result'} = '⇒';
-$things_map{'bullet'} = '•';
-$things_map{'copyright'} = '©right;';
-$things_map{'registeredsymbol'} = '®istered;';
-$things_map{'arrow'} = '→';
-$things_map{'TeX'} = '&tex;';
-$things_map{'LaTeX'} = '&latex;';
-
-%pre_map = %things_map;
-
-$stop_paragraph_command{'caption'} = 1;
-$stop_paragraph_command{'shortcaption'} = 1;
-
-%line_command_map = ();
-
-$format_map{'copying'} = '';
-$format_map{'titlepage'} = 'titlepage';
-$format_map{'documentdescription'} = 'documentdescription';
-$format_map{'group'} = 'group';
-
-foreach my $region ('titlepage', 'documentdescription', 'copying')
-{
- $region_formats_kept{$region} = 1;
-}
-
-foreach my $style (keys(%style_map))
-{
- next if grep {$style eq $_} ('asis', 'ctrl', 'w', 'tieaccent', 'dotless',
keys(%unicode_accents));
- if (!exists($style_map{$style}->{'args'}) or
(scalar(@{$style_map{$style}->{'args'}}) eq 1 and
$style_map{$style}->{'args'}->[0] eq 'code'))
- {
- $style_map{$style}->{'attribute'} = $style;
- delete ($style_map{$style}->{'quote'});
- delete ($style_map{$style}->{'begin'});
- delete ($style_map{$style}->{'end'});
- }
-}
-
-foreach my $complex_format (keys(%$complex_format_map))
-{
- my $style = $complex_format_map->{$complex_format}->{'style'};
- delete $complex_format_map->{$complex_format};
- $complex_format_map->{$complex_format}->{'begin'} = "\"<$complex_format
xml:space=\\\"preserve\\\">\"";
- $complex_format_map->{$complex_format}->{'end'} = "\"</$complex_format>\"";
- $complex_format_map->{$complex_format}->{'style'} = $style if
(defined($style));
-}
-
-delete $iso_symbols{'`'};
-delete $iso_symbols{"'"};
-delete $style_map{'verb'}->{'attribute'};
-$style_map{'indicateurl'}->{'attribute'} = 'url';
-$style_map{'w'}->{'end'} = '<!-- /@w -->';
-$style_map{'='}->{'function'} = \&xml_macron;
-$style_map{'email'}->{'function'} = \&xml_email;
-$style_map{'titlefont'}->{'function'} = \&xml_titlefont;
-$style_map{'math'}->{'function'} = \&xml_math;
-$style_map{'uref'}->{'function'} = \&xml_uref;
-$style_map{'url'}->{'function'} = \&xml_uref;
-$style_map{'t'}->{'attribute'} = 'tt';
-# FIXME
-delete $special_accents{'ringaccent'};
-$special_accents{'ogonek'} = 'aeiuAEIU';
-
-%style_map_pre = %style_map;
-
-sub xml_macron($$)
-{
- my $accent = shift;
- my $args = shift;
- return $args->[0] . "¯";
-}
-
-sub xml_email($$)
-{
- my $command = shift;
- my $args = shift;
- my $mail = shift @$args;
- my $text = shift @$args;
- $mail = main::normalise_space($mail);
- my $result = "<email><emailaddress>$mail</emailaddress>";
- if (defined($text) and $text =~ /\S/)
- {
- $result .= "<emailname>".main::normalise_space($text)."</emailname>";
- }
- return $result . '</email>';
-}
-
-sub xml_uref($$)
-{
- shift;
- my $args = shift;
- my $url = shift @$args;
- my $text = shift @$args;
- my $replacement = shift @$args;
- $url = main::normalise_space($url);
- $replacement = '' if (!defined($replacement));
- $replacement = main::normalise_space($replacement);
- $text = '' if (!defined($text));
- $text = main::normalise_space($text);
- my $result = "<uref><urefurl>$url</urefurl>";
- $result .= "<urefdesc>$text</urefdesc>" if ($text ne '');
- $result .= "<urefreplacement>$replacement</urefreplacement>" if
($replacement ne '');
- return $result.'</uref>';
-}
-
-
-sub xml_titlefont($$)
-{
- shift;
- my $args = shift;
- return "<titlefont>$args->[0]</ititlefont>" if ($args->[0] =~ /\S/);
- return '';
-}
-
-sub xml_math($$)
-{
- shift;
- my $args = shift;
- my $text = shift @$args;
- $text =~ s/[{}]//g;
- return "<math>$text</math>";
-}
-
-
-$no_paragraph_commands{'cindex'} = 0;
-
-#my @xml_ignored_misc_commands = ('bye', 'sp', 'verbatiminclude');
-
-my @xml_ignored_misc_commands = ('bye', 'sp', 'verbatiminclude', 'clickstyle',
- 'defcodeindex',
- 'syncodeindex', 'paragraphindent', 'shorttitlepage', 'refill', 'noindent');
-
-# we want to proceed all the misc commands
-# makeinfo ignores clickstyle, changes setfilename. Not sure it is right.
-foreach my $misc_command (keys(%misc_command))
-{
- next if (grep {$misc_command eq $_} @xml_ignored_misc_commands);
- $misc_command{$misc_command}->{'keep'} = 1;
-}
-
-$format_map{'menu'} = 'menu';
-# checked on bug-texinfo, only node is in code_style, as with makeinfo --xml
-#$format_code_style{'menu'} = 1;
-#$format_code_style{'menu_name'} = 1;
-#$format_code_style{'menu_description'} = 1;
-$format_map{'detailmenu'} = 'detailmenu';
-$format_map{'direntry'} = 'direntry';
-$format_map{'menu_comment'} = '';
-delete $format_map{'enumerate'};
-foreach my $table ('table', 'ftable', 'vtable')
-{
- #$format_map{$table} = 'table';
- delete $format_map{$table};
-}
-
-$menu_description = \&xml_menu_description;
-$menu_link = \&xml_menu_link;
-$element_heading = \&xml_heading;
-$heading = \&xml_heading;
-$heading_texi = \&xml_heading_texi;
-$paragraph = \&xml_paragraph;
-$preformatted = \&xml_preformatted;
-$misc_element_label = \&xml_noop;
-$element_label = \&xml_noop;
-$anchor_label = \&xml_anchor_label;
-$index_entry_label = \&xml_index_entry_label;
-$index_entry_command = \&xml_index_entry_command;
-$listoffloats = \&xml_listoffloats;
-$acronym_like = \&xml_acronym_like;
-$foot_line_and_ref = \&xml_foot_line_and_ref;
-$image = \&xml_image;
-$sp = \&xml_sp;
-$quotation = \&xml_quotation;
-$table_list = \&xml_table_list;
-$row = \&xml_row;
-$cell = \&xml_cell;
-$list_item = \&xml_list_item;
-$format_list_item_texi = \&xml_format_list_item_texi;
-$unknown = \&xml_misc_commands;
-$begin_format_texi = \&xml_begin_format_texi;
-$def_line = \&xml_def_line;
-$def = \&xml_def;
-$def_item = \&xml_def_item;
-$printindex = \&xml_printindex;
-$index_summary = \&xml_index_summary;
-$external_ref = \&xml_external_ref;
-$internal_ref = \&xml_internal_ref;
-$table_item = \&xml_table_item;
-$table_line = \&xml_table_line;
-$float = \&xml_float;
-$caption_shortcaption = \&xml_caption_shortcaption;
-$caption_shortcaption_command = \&xml_caption_shortcaption_command;
-$normal_text = \&xml_normal_text;
-$paragraph_style_command = \&xml_paragraph_style_command;
-$raw = \&xml_raw;
-$cartouche = \&xml_cartouche;
-
-$print_Top = \&xml_print_Top;
-$print_Top_footer = \&xml_print_Top_footer;
-$print_page_head = \&xml_print_page_head;
-#$print_navigation = \&xml_noop;
-$print_foot_navigation = \&xml_noop;
-$toc_body = \&xml_noop;
-$about_body = \&xml_noop;
-$print_page_foot = \&xml_print_page_foot;
-$end_section = \&xml_end_section;
-$one_section = \&xml_one_section;
-
-sub xml_menu_description($$$)
-{
- my $text = shift;
- my $state = shift;
- my $element_text = shift;
- return "<menucomment>$text</menucomment>\n</menuentry>";
-}
-
-sub xml_menu_link($$$$$$$)
-{
- my $entry = shift;
- my $state = shift;
- my $href = shift;
- my $menunode = shift;
- my $menutitle = shift;
- my $ending = shift;
- my $has_title = shift;
-
- return
"<menuentry>\n<menunode>$menunode</menunode>\n<menutitle>$menutitle</menutitle>\n";
-}
-
-sub xml_print_page_head($)
-{
- my $fh = shift;
- my $setfilename = '';
- $setfilename =
"<setfilename>$Texi2HTML::THISDOC{file_base_name}.$EXTENSION</setfilename>"
- unless (defined($Texi2HTML::THISDOC{'setfilename'}) and
$Texi2HTML::THISDOC{'setfilename'} ne '');
- my $language = get_conf('documentlanguage');
- print $fh <<EOT;
-<?xml version="1.0"?>
-$DOCTYPE
-<texinfo xml:lang="$language">
-$setfilename
-EOT
-}
-
-sub xml_print_page_foot($)
-{
- my $fh = shift;
- print $fh <<EOT;
-</texinfo>
-<!-- Keep this comment at the end of the file
-Local variables:
-mode: sgml
-sgml-indent-step:1
-sgml-indent-data:nil
-End:
--->
-EOT
-}
-
-sub xml_heading_texi($$$)
-{
- my $tag = shift;
- my $texi = shift;
- my $number = shift;
- $texi =~ s/\s*$//;
- $texi =~ s/^\s*//;
- return $texi;
-}
-
-sub xml_one_section($$)
-{
- my $fh = shift;
- my $element = shift;
- main::print_lines($fh);
- print $fh "". xml_footing($element);
- &$print_foot_navigation($fh);
- &$print_page_foot($fh);
-}
-
-sub xml_heading($$$$$)
-{
- my $element = shift;
- my $command = shift;
- my $texi_line = shift;
- my $line = shift;
- my $in_preformatted = shift;
-
-#print STDERR "'$command' $line";
- if (defined($command) and $command =~ /heading/)
- {
- my $text = '';
- if (defined($line))
- {
- $text = $line;
- # this isn't done in main program in that case...
- chomp ($text);
- $text =~ s/^\s*//;
- }
- return "<${command}>$text</${command}>\n";
- }
-
- my $node_element;
- if ($element->{'node'})
- {
- $node_element = $element;
- }
- elsif (defined($element->{'node_ref'}))
- {
- $node_element = $element->{'node_ref'};
- }
-
- my $result = '';
- if (defined($node_element) and $command eq 'node')
- {
-#print STDERR "node $command $node_element->{'texi'}\n";
- $result .= "<node>\n";
- $result .= "<nodename>$node_element->{'text'}</nodename>\n";
- foreach my $direction('nodenext', 'nodeprev', 'nodeup')
- {
- if ($node_element->{$direction})
- {
- $result .=
"<${direction}>$node_element->{$direction}->{'text'}</${direction}>\n";
- }
- }
- }
-
- if (!$element->{'node'})
- {
- my $class = $element->{'tag_level'};
- # FIXME wrong?
- $class = 'unnumbered' if ($class eq 'top' or $class eq 'centerchap');
- $result .= "<${class}>\n<title>$element->{'text'}</title>\n";
- }
- return $result;
-}
-
-sub xml_footing($)
-{
- my $element = shift;
-
- my $result = '';
- if (!$element->{'node'})
- {
- my $class = $element->{'tag_level'};
- # FIXME wrong?
- $class = 'unnumbered' if ($class eq 'top' or $class eq 'centerchap');
- $result .= "</${class}>\n";
- }
- if ($element->{'node'} or defined($element->{'node_ref'}))
- {
- $result .= "</node>\n";
- }
- return $result;
-}
-
-sub xml_end_section($$$)
-{
- my $fh = shift;
- my $end_foot_navigation = shift;
- my $element = shift;
- print $fh "". xml_footing($element);
-}
-
-sub xml_print_Top($$$)
-{
- my $fh = shift;
- my $has_top_heading = shift;
- my $element = shift;
- #print $fh "".xml_heading($element);
- main::print_lines($fh, $Texi2HTML::THIS_SECTION);
-}
-
-sub xml_print_Top_footer($$)
-{
- my $fh = shift;
- my $end_page = shift;
- my $element = shift;
-
- print $fh "". xml_footing($element);
-}
-
-# FIXME warning:
-#
-# @code{first para
-#
-# second para}.
-#
-# leads to:
-# <para><code>first para second para</code>.</para>
-sub xml_paragraph($$$$$$$$$$$$)
-{
- my $text = shift;
- my $align = shift;
- my $indent = shift;
- my $paragraph_command = shift;
- my $paragraph_command_formatted = shift;
- my $paragraph_number = shift;
- my $format = shift;
- my $item_nr = shift;
- my $enumerate_style = shift;
- my $number = shift;
- my $command_stack_at_end = shift;
- my $command_stack_at_begin = shift;
-
- foreach my $style(t2h_collect_styles($command_stack_at_begin))
- {
- $text = t2h_begin_style($style, $text);
- }
- foreach my $style(t2h_collect_styles($command_stack_at_end))
- {
- $text = t2h_end_style($style, $text);
- }
-
- # no para in multitables, caption and shortcaptions.
- my $top_stack = '';
- $top_stack = $command_stack_at_begin->[-1] if (scalar
(@$command_stack_at_begin));
- return $text if ($top_stack eq 'multitable' or $top_stack eq
'shortcaption' or $top_stack eq 'caption' or $top_stack eq
'documentdescription');
-
- if ($text =~ /\S/)
- {
- return "<para>$text</para>";
- }
- return $text;
-}
-
-sub xml_preformatted($$$$$$$$$$$$)
-{
- my $text = shift;
- my $pre_style = shift;
- my $class = shift;
- my $leading_command = shift;
- my $leading_command_formatted = shift;
- my $preformatted_number = shift;
- my $format = shift;
- my $item_nr = shift;
- my $enumerate_style = shift;
- my $number = shift;
- my $command_stack_at_end = shift;
- my $command_stack_at_begin = shift;
-
- return $text;
-}
-
-my %xml_misc_elements_with_arg_map = (
- 'title' => 'booktitle',
- 'subtitle' => 'booksubtitle'
-);
-
-my @xml_misc_elements_with_arg = ('author',
- 'dircategory', 'settitle');
-#my @xml_misc_elements_with_arg = ('author', 'shorttitlepage',
-# 'vskip', 'dircategory', 'settitle');
-
-sub xml_misc_commands($$$$$)
-{
- my $macro = shift;
- my $line = shift;
- my $pass = shift;
- my $stack = shift;
- my $state = shift;
-#print STDERR "$macro $pass $line";
- return ($line, 0, undef, undef) unless ($pass == 2);
- return ($line, 0, undef, undef) unless defined($misc_command{$macro});
-
- my $value_name = '';
- my $value = '';
- if ($macro eq 'set' or $macro eq 'clear')
- {
- my $value_line = $line;
- if ($value_line =~ s/^\s+([\w\-]+)//)
- {
- $value_name = $1;
- if ($macro eq 'set')
- {
- $value = $value_line;
- chomp ($value);
- $value =~ s/^\s*//;
- }
- }
- }
- my ($result_line, $text, $args) = &$preserve_misc_command ($line, $macro);
-#print STDERR "$macro $pass $line";
-#print STDERR "ARGS @$args\n" if defined ($args);
- my $result_text = "<${macro}></${macro}>";
- if ($macro eq 'set' or $macro eq 'clear')
- {
- $result_text = "<${macro}value
name=\"$value_name\">$value</${macro}value>\n";
- }
- if ($macro eq 'c' or $macro eq 'comment' and scalar(@$args))
- {
- my $comment_line = $args->[0];
- chomp ($comment_line);
- # makeinfo remove all the leading spaces
- $comment_line =~ s/^\s//;
- $result_text = &$comment ($comment_line);
- }
- if ($macro eq 'frenchspacing')
- {
- my $value = $args->[0];
- $value =~ s/\s*//g;
- $result_text = "<${macro} var=\"$value\"></${macro}>";
- }
- if (grep {$macro eq $_} @xml_misc_elements_with_arg)
- {
- my $arg = $args->[0];
- $arg =~ s/^\s*//;
- chomp($arg);
- $result_text = "<${macro}>".main::substitute_line($arg,
"address@hidden")."</${macro}>\n";
- }
- if (exists($xml_misc_elements_with_arg_map{$macro}))
- {
- my $arg = $args->[0];
- $arg =~ s/^\s*//;
- chomp($arg);
- $result_text =
"<$xml_misc_elements_with_arg_map{$macro}>".main::substitute_line($arg,
"address@hidden")."</$xml_misc_elements_with_arg_map{$macro}>\n";
- }
- if ($macro eq 'setfilename')
- {
- my $arg = $args->[0];
- $arg =~ s/^\s*//;
- $arg =~ s/\s*$//;
- $arg = main::substitute_line($arg, "address@hidden");
- $arg =~ s/\.[^\.]*$//;
- $result_text = "<${macro}>${arg}.xml</${macro}>\n";
- }
- return ($result_line, 1, $result_text, undef);
-}
-
-
-sub xml_anchor_label($$)
-{
- my $id = shift;
- my $anchor_text = shift;
- return '<anchor name="'. &$protect_text($anchor_text) . '"></anchor>';
-}
-
-sub xml_index_entry_command($$$$$)
-{
- my $command = shift;
- my $index_name = shift;
- my $label = shift;
- my $entry_texi = shift;
- my $entry_formatted = shift;
-
- return $label if (defined($label) and $label ne '');
- return
xml_index_entry_label('','','',$main::index_prefix_to_name{$index_name}, '',
'', $entry_formatted);
-}
-
-sub xml_index_entry_label($$$$$$$$)
-{
- my $identifier = shift;
- my $preformatted = shift;
- my $formatted_entry = shift;
- my $index_name = shift;
- my $index_command = shift;
- my $texi_entry = shift;
- my $formatted_entry_reference = shift;
- my $entry = shift;
-
-
- return "<indexterm
index=\"${index_name}\">${formatted_entry_reference}</indexterm>";
-}
-
-sub xml_listoffloats($$$)
-{
- my $style_texi = shift;
- my $style = shift;
- my $float_entries = shift;
- # FIXME style, style_texi? Protected?
- return "<listoffloats type=\"$style\"></listoffloats>";
-}
-
-sub xml_acronym_like($$$$$$)
-{
- my $command = shift;
- my $acronym_texi = shift;
- my $acronym_text = shift;
- my $with_explanation = shift;
- my $explanation_lines = shift;
- my $explanation_text = shift;
- my $explanation_simply_formatted = shift;
-
- $command = 'abbrev' if ($command eq 'abbr');
- my $opening = "<${command}><${command}word>$acronym_text</${command}word>";
- if ($with_explanation)
- {
- $opening .= "<${command}desc>$explanation_text</${command}desc>";
- }
- return $opening . "</${command}>";
-}
-
-sub xml_foot_line_and_ref($$$$$$$)
-{
- my $number_in_doc = shift;
- my $number_in_page = shift;
- my $footnote_id = shift;
- my $place_id = shift;
- my $document_file = shift;
- my $footnote_file = shift;
- my $lines = shift;
- my $state = shift;
-
- my $result = '<footnote>';
- foreach my $line (@$lines)
- {
- $result .= $line;
- }
- return ([], $result . '</footnote>');
-}
-
-sub xml_image($$$$$$$$$$$$$)
-{
- my $file = shift;
- my $base = shift;
- my $preformatted = shift;
- my $file_name = shift;
- my $alt = shift;
- my $width = shift;
- my $height = shift;
- my $raw_alt = shift;
- my $extension = shift;
- my $working_dir = shift;
- my $file_path = shift;
- my $in_paragraph = shift;
- my $file_locations = shift;
-
- $alt = '' if (!defined($alt));
- # dirty hack to avoid " that can be here because of a @verb
- $alt =~ s/"/"/g;
-
- $width = '' if (!defined($width));
- $height = '' if (!defined($height));
-
- my $tag = 'inlineimage';
- $tag = 'image' if ($preformatted or !$in_paragraph);
-
- return "<$tag width=\"$width\" height=\"$height\" name=\"".
&$protect_text($base)."\"
extension=\"$extension\"><alttext>$alt</alttext></$tag>";
-}
-
-sub xml_sp($$)
-{
- my $number = shift;
- my $preformatted = shift;
- return "<sp lines=\"$number\"></sp>\n";
-}
-
-sub xml_quotation($$$$)
-{
- my $command = shift;
- my $text = shift;
- my $argument_text = shift;
- my $argument_text_texi = shift;
- return "<$command>\n" . $text . "</$command>\n";
-}
-
-sub xml_format_list_item_texi($$$$)
-{
- my $format = shift;
- my $line = shift;
- my $prepended = shift;
- my $command = shift;
-
- my $result_line = undef;
-
- if (defined($command) and $command ne '' and !exists
$special_list_commands{$format}->{$command} and $format ne 'itemize')
- {
- address@hidden
- $line =~ s/^\s*//;
- $line =~ s/\s*$//;
- if (exists ($style_map{$command}))
- {
- $result_line = "address@hidden";
- }
- elsif (exists ($things_map{$command}))
- {
- $result_line = "address@hidden $line\n";
- }
- else
- {
- $result_line = "address@hidden $line\n";
- }
- }
-
- return ($result_line, 0);
-}
-
-sub xml_list_item($$$$$$$$$)
-{
- my $text = shift;
- my $format = shift;
- my $command = shift;
- my $formatted_command = shift;
- my $item_nr = shift;
- my $enumerate_style = shift;
- my $number = shift;
- my $prepended = shift;
- my $prepended_formatted = shift;
-
- return '<item>' . $text . "</item>\n";
-}
-
-my @xml_multitable_stack = ();
-my @xml_table_stack = ();
-
-sub xml_init_variables()
-{
- @xml_multitable_stack = ();
- @xml_table_stack = ();
-}
-
-# row in multitable
-sub xml_row($$;$$)
-{
- my $text = shift;
- my $macro = shift;
- my $columnfractions = shift;
- my $prototype_row = shift;
- my $prototype_lengths = shift;
- my $column_number = shift;
-
- my $result = '';
- if ($macro eq 'headitem')
- {
- if ($xml_multitable_stack[-1] != 0)
- {
- $result .= "<thead>";
- $result = "</tbody>" . $result if ($xml_multitable_stack[-1] ==
1);
- $xml_multitable_stack[-1] = 0;
- }
- }
- elsif ($xml_multitable_stack[-1] != 1)
- {
- $result .= "<tbody>";
- $result = "</thead>" . $result if ($xml_multitable_stack[-1] == 0);
- $xml_multitable_stack[-1] = 1;
- }
- $result .= "<row>$text</row>";
-
- return $result;
-}
-
-# cell in multitable
-sub xml_cell($$;$$)
-{
- my $text = shift;
- my $row_macro = shift;
- my $columnfractions = shift;
- my $prototype_row = shift;
- my $prototype_lengths = shift;
- my $column_number = shift;
-
- return "<entry>" . $text . '</entry>';
-}
-
-sub xml_table_list($$$$$$$$$)
-{
- my $format_command = shift;
- my $text = shift;
- my $command = shift;
- my $formatted_command = shift;
-# enumerate
- my $item_nr = shift;
- my $enumerate_style = shift;
-# itemize
- my $prepended = shift;
- my $prepended_formatted = shift;
-# multitable
- my $columnfractions = shift;
- my $prototype_row = shift;
- my $prototype_lengths = shift;
- my $number = shift;
-
- my $result = "<$format_command>";
- if ($format_command eq 'itemize')
- {
- my $itemfunction;
- $prepended_formatted =~ s/^\s*// if (defined($prepended_formatted));
- if (defined($formatted_command) and $formatted_command ne '')
- {
- $itemfunction = $formatted_command;
- $itemfunction .= " $prepended_formatted" if
(defined($prepended_formatted) and $prepended_formatted ne '');
- }
- elsif (defined($prepended_formatted))
- {
- $itemfunction = $prepended_formatted;
- }
- $itemfunction = "•" if (!defined($itemfunction) or
- $itemfunction eq '');
- $result .= "<itemfunction>$itemfunction</itemfunction>";
- }
- elsif ($format_command eq 'enumerate')
- {
- $result = "<$format_command first=\"$enumerate_style\">";
- }
- elsif ($format_command eq 'multitable')
- {
- my $fractions;
- my $multiply = 1;
- if (defined($columnfractions) and (ref($columnfractions) eq 'ARRAY')
- and scalar(@$columnfractions))
- {
- $fractions = [ @$columnfractions ];
- $multiply = 100;
- }
- elsif (defined($prototype_lengths) and (ref($prototype_lengths) eq
'ARRAY')
- and scalar(@$prototype_lengths))
- {
- $fractions = [ @$prototype_lengths ];
- }
-
- if (defined ($fractions))
- {
- foreach my $fraction (@$fractions)
- {
- $result .=
"<columnfraction>".($fraction*$multiply)."</columnfraction>\n";
- }
- }
- $text .= "</tbody>" if ($xml_multitable_stack[-1] == 1);
- $text .= "</thead>" if ($xml_multitable_stack[-1] == 0);
- pop @xml_multitable_stack;
- }
- elsif ($format_command =~ /^(v|f)?table$/)
- {
- $result = '<table>';
- $text .= '</tableitem>' if ($xml_table_stack[-1] == 1);
- pop @xml_table_stack;
- return $result . "$text</table>\n";
- }
- return $result . "$text</$format_command>\n";
-}
-
-sub xml_begin_format_texi($$$)
-{
- my $command = shift;
- my $line = shift;
- my $state = shift;
-
- push (@xml_multitable_stack, -1) if ($command eq 'multitable');
- push (@xml_table_stack, 0) if ($command =~ /^(v|f)?table/);
- return $line;
-}
-
-my %def_format_xml = (
- 'deffn' => [ ['category', 'category'], ['function', 'name'] ],
- 'defvr' => [ ['category', 'category'], ['variable', 'name'] ],
- 'deftypefn' => [ ['category', 'category'], ['type', 'type'], ['function',
'name'] ],
- 'deftypeop' => [ ['category', 'category'], ['type', 'type'], ['operation',
'name'] ],
- 'deftypevr' => [ ['category', 'category'], ['type', 'type'], ['variable',
'name'] ],
- 'defcv' => [ ['category' , 'category'], ['class', 'class'], ['classvar',
'name'] ],
- 'deftypecv' => [ ['category', 'category'], ['type', 'type'], ['classvar',
'name'] ],
- 'defop' => [ ['category', 'category'], ['class', 'class'], ['operation',
'name'] ],
- 'deftp' => [ ['category', 'category'], ['datatype', 'name'] ]
-);
-
-sub xml_def_line($$$$$$$$$$$$$$$)
-{
- my $category_prepared = shift;
- my $name = shift;
- my $type = shift;
- my $arguments = shift;
- my $index_label = shift;
- my $arguments_array = shift;
- my $arguments_type_array = shift;
- my $unformatted_arguments_array = shift;
- my $command = shift;
- my $class_name = shift;
- my $category = shift;
- my $class = shift;
- my $style = shift;
- my $original_command = shift;
-
- my $result = "<definitionterm><indexterm index=\""
- .$main::index_prefix_to_name{$style}."\">$class_name</indexterm>";
-
- my %arguments = ( 'prepared_category' => $category_prepared,
- 'category' => $category,
- 'name' => $name,
- 'type' => $type,
- 'class' => $class
- );
- foreach my $type (keys(%arguments))
- {
- $arguments{$type} = '' if (!defined($arguments{$type}));
- }
-
- foreach my $mandatory_arg (@{$def_format_xml{$command}})
- {
- my $elem = $mandatory_arg->[0];
- $result .= "<def$elem>$arguments{$mandatory_arg->[1]}</def$elem>";
- }
-
- my $params = '';
- my @types = @$arguments_type_array;
- foreach my $arg (@$arguments_array)
- {
- my $type = shift @types;
- if (grep {$_ eq $type} ('param', 'paramtype', 'delimiter'))
- {
- $result .= "<def$type>$arg</def$type>";
- }
- }
-
- $result .= "</definitionterm>\n";
- return $result;
-}
-
-# FIXME
-# @deffn
-# @c comment
-# @end deffn
-# leads to the creation of a <definitionitem> with a comment within,
-# while there should be no definitionitem
-sub xml_def_item($$)
-{
- my $text = shift;
- my $only_inter_item_commands = shift;
-
- if ($text =~ /\S/)
- {
- return '<definitionitem>' . $text . '</definitionitem>' unless
$only_inter_item_commands;
- return $text;
- }
- return '';
-}
-
-sub xml_def($)
-{
- my $text = shift;
- return '<definition>'.$text.'</definition>';
-}
-
-sub xml_index_summary($$)
-{
- my $alpha = shift;
- my $nonalpha = shift;
- return '';
-}
-
-sub xml_printindex($)
-{
- my $name = shift;
- return "<printindex>$name</printindex>\n";
-}
-
-sub xml_any_ref($$)
-{
- my $type = shift;
- my $args = shift;
- my $result = '';
- if ($type eq 'pxref')
- {
- $result = &$I('see ',{'duplicate'=>1});
- }
- elsif ($type eq 'xref' or $type eq 'inforef')
- {
- $result = &$I('See ',{'duplicate'=>1});
- }
- if ($type eq 'inforef')
- {
- $result .= "<inforef><inforefnodename>$args->[0]</inforefnodename>";
- $result .= "<inforefrefname>$args->[1]</inforefrefname>" if
($args->[1] ne '');
- $result .= "<inforefinfoname>$args->[2]</inforefinfoname></inforef>"
- }
- else
- {
- $result .= "<xref><xrefnodename>$args->[0]</xrefnodename>";
- $result .= "<xrefinfoname>$args->[1]</xrefinfoname>" if ($args->[1] ne
'');
- $result .= "<xrefprinteddesc>$args->[2]</xrefprinteddesc>" if
($args->[2] ne '');
- $result .= "<xrefinfofile>$args->[3]</xrefinfofile>" if ($args->[3] ne
'');
- $result .= "<xrefprintedname>$args->[4]</xrefprintedname>" if
($args->[4] ne '');
- $result .= '</xref>';
- }
- return $result;
-}
-
-sub xml_external_ref($$$$$$)
-{
- my $type = shift;
- my $section = shift;
- my $book = shift;
- my $file_node = shift;
- my $href = shift;
- my $cross_ref = shift;
- my $args_texi = shift;
- my $formatted_args = shift;
-
- return xml_any_ref ($type, $formatted_args);
-}
-
-sub xml_internal_ref($$$$$)
-{
- my $type = shift;
- my $href = shift;
- my $short_name = shift;
- my $name = shift;
- my $is_section = shift;
- my $args_texi = shift;
- my $formatted_args = shift;
-
- return xml_any_ref ($type, $formatted_args);
-}
-
-sub xml_table_item($$$$$$$)
-{
- my $text = shift;
- my $index_label = shift;
- my $format = shift;
- my $command = shift;
-# my $formatted_command = shift;
- my $style_stack = shift;
-# my $text_formatted = shift;
-# my $text_formatted_leading_spaces = shift;
-# my $text_formatted_trailing_spaces = shift;
- my $item_cmd = shift;
- my $formatted_index_entry = shift;
-
-
-# $formatted_command = '' if (!defined($formatted_command));
-#
-# if (defined($text_formatted))
-# {
-# $text_item = $text_formatted_leading_spaces . $text_formatted
.$text_formatted_trailing_spaces;
-# }
-# else
-# {
-# $text_item = $text;
-# }
-
- my $result = '';
- if ($item_cmd eq 'item')
- {
- $result .= '</tableitem>' if ($xml_table_stack[-1] == 1);
- $xml_table_stack[-1] = 1;
- $result .= '<tableitem>';
- }
- $result .= '<tableterm>';
- #print STDERR "$text | $format | $command | $formatted_command |
$text_formatted | $item_cmd \n";
- my $indexterm = '';
-#print STDERR "FFFFFFFFFFFFFFFFf `$index_label' `$text'\n";
- if ($format =~ /^(v|f)/)
- {
-# my $index_prefix = $1;
-# $indexterm = $text;
-# $indexterm =~ s/^\s*//;
-# $result .= "<indexterm
index=\"$main::index_prefix_to_name{$index_prefix}\">$formatted_index_entry</indexterm>";
- $result .= "$index_label";
- }
- $result .= $text ."</tableterm>\n";
- return $result;
-}
-
-sub xml_table_line($)
-{
- my $text = shift;
- my $only_inter_item_commands = shift;
- my $before_items = shift;
-
- if ($text =~ /\S/)
- {
- return "<item>$text</item>" unless $only_inter_item_commands;
- return $text;
- }
- else
- {
- return '';
- }
-}
-
-sub xml_caption_shortcaption($)
-{
- my $float = shift;
- my $caption_lines;
- my $shortcaption_lines;
- if (defined($float->{'caption_texi'}))
- {
- @$caption_lines = @{$float->{'caption_texi'}};
- }
- if (defined($float->{'shortcaption_texi'}))
- {
- @$shortcaption_lines = @{$float->{'shortcaption_texi'}};
- }
- return ($caption_lines, $shortcaption_lines);
-}
-
-sub xml_caption_shortcaption_command($$$)
-{
- my $command = shift;
- my $text = shift;
- my $texi_lines = shift;
- my $float_element = shift;
-
- if ($text =~ /\S/)
- {
- return "<$command>$text</$command>";
- }
- return '';
-}
-
-sub xml_float($$$$$)
-{
- my $text = shift;
- my $float = shift;
- my $caption = shift;
- my $shortcaption = shift;
-
- my $label_texi = $float->{'texi'};
- $label_texi = '' if (!defined($label_texi));
- my $result = "<float name=\"$label_texi\">\n";
- my $style = $float->{'style'};
- $style = '' if (!defined($style));
- $result .= "<floattype>$style</floattype>\n";
- $result .= "<floatpos></floatpos>\n";
- $result .= $text;
- return $result."</float>\n";
-}
-
-sub xml_normal_text($$$$$$)
-{
- my $text = shift;
- my $in_raw_text = shift;
- my $in_preformatted = shift;
- my $in_code = shift;
- my $in_simple = shift;
-#print STDERR "Bug: in_raw_text in_simple $text\n" if ($in_raw_text and
$in_simple);
- my $style_stack = shift;
- $text = &$protect_text($text) unless($in_raw_text);
-
- if (! $in_code and !$in_preformatted and !$in_raw_text)
- {
- $text =~ s/---/\&mdash\;/g;
- $text =~ s/--/\&ndash\;/g;
- $text =~ s/``/\&ldquo\;/g;
- $text =~ s/''/\&rdquo\;/g;
- }
- return $text;
-}
-
-sub xml_paragraph_style_command($$)
-{
- my $format = shift;
- my $text = shift;
- return "<$format>$text</$format>" if ($format eq 'center');
- return $text;
-}
-
-sub xml_raw($$)
-{
- my $style = shift;
- my $text = shift;
-
- if ($style eq 'verbatim' or $style eq 'verbatiminclude')
- {
- return '<verbatim xml:space="preserve">' . &$protect_text($text) .
'</verbatim>';
- }
- return '' unless (grep {$style eq $_} @EXPAND);
- if ($style eq 'xml')
- {
- chomp ($text);
- return $text;
- }
- else
- {
- main::echo_warn ("Raw style $style not handled");
- return &$protect_text($text);
- }
-}
-
-sub xml_cartouche($$)
-{
- my $text = shift;
-
- return "<cartouche>$text</cartouche>";
-}
-
-sub xml_noop
-{
- return '';
-}
-
-1;
- [Texi2html-cvs] texi2html ChangeLog Makefile.am Makefile.in NEW...,
Patrice Dumas <=