texi2html-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Texi2html-cvs] texi2html ChangeLog T2h_i18n.pm TODO texi2html....


From: Patrice Dumas
Subject: [Texi2html-cvs] texi2html ChangeLog T2h_i18n.pm TODO texi2html....
Date: Sat, 27 Dec 2008 20:53:25 +0000

CVSROOT:        /cvsroot/texi2html
Module name:    texi2html
Changes by:     Patrice Dumas <pertusus>        08/12/27 20:53:25

Modified files:
        .              : ChangeLog T2h_i18n.pm TODO texi2html.init 
                         texi2html.pl 
        examples       : docbook.init html32.init info.init xml.init 

Log message:
                * texi2html.pl: add new hooks for user functions, for simple 
                @-commands, and at the beginning of special regions.
                * T2h_i18n.pm, texi2html.pl, texi2html.init, examples/*: 
                use main state in translation string only when needed.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texi2html/ChangeLog?cvsroot=texi2html&r1=1.347&r2=1.348
http://cvs.savannah.gnu.org/viewcvs/texi2html/T2h_i18n.pm?cvsroot=texi2html&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/texi2html/TODO?cvsroot=texi2html&r1=1.75&r2=1.76
http://cvs.savannah.gnu.org/viewcvs/texi2html/texi2html.init?cvsroot=texi2html&r1=1.171&r2=1.172
http://cvs.savannah.gnu.org/viewcvs/texi2html/texi2html.pl?cvsroot=texi2html&r1=1.251&r2=1.252
http://cvs.savannah.gnu.org/viewcvs/texi2html/examples/docbook.init?cvsroot=texi2html&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/texi2html/examples/html32.init?cvsroot=texi2html&r1=1.21&r2=1.22
http://cvs.savannah.gnu.org/viewcvs/texi2html/examples/info.init?cvsroot=texi2html&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/texi2html/examples/xml.init?cvsroot=texi2html&r1=1.11&r2=1.12

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/texi2html/texi2html/ChangeLog,v
retrieving revision 1.347
retrieving revision 1.348
diff -u -b -r1.347 -r1.348
--- ChangeLog   23 Dec 2008 14:02:24 -0000      1.347
+++ ChangeLog   27 Dec 2008 20:53:24 -0000      1.348
@@ -1,3 +1,10 @@
+2008-12-24  Patrice Dumas  <address@hidden>
+
+       * texi2html.pl: add new hooks for user functions, for simple 
+       @-commands, and at the beginning of special regions.
+       * T2h_i18n.pm, texi2html.pl, texi2html.init, examples/*: 
+       use main state in translation string only when needed.
+
 2008-12-23  Patrice Dumas  <address@hidden>
 
        * texi2html.pl: correct transliteration when USE_UNICODE or 

Index: T2h_i18n.pm
===================================================================
RCS file: /cvsroot/texi2html/texi2html/T2h_i18n.pm,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- T2h_i18n.pm 8 Aug 2008 12:07:22 -0000       1.24
+++ T2h_i18n.pm 27 Dec 2008 20:53:24 -0000      1.25
@@ -314,7 +314,9 @@
     my $string = shift;
     my $arguments = shift;
     my $state = shift;
-    if (!defined($state) and defined($Texi2HTML::THISDOC{'state'}))
+    # if duplicate is passed, it means that we are in the text and so should
+    # use the main state
+    if (defined($state) and $state->{'duplicate'} and 
defined($Texi2HTML::THISDOC{'state'}))
     {
         $state = 
main::duplicate_formatting_state($Texi2HTML::THISDOC{'state'});
     }

Index: TODO
===================================================================
RCS file: /cvsroot/texi2html/texi2html/TODO,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -b -r1.75 -r1.76
--- TODO        23 Dec 2008 10:55:30 -0000      1.75
+++ TODO        27 Dec 2008 20:53:24 -0000      1.76
@@ -49,6 +49,7 @@
   $copying_comment, $titlepage better and $documentdescription
   $program_string
   $heading arguments $begin_paragraph_texi $tab_item_texi $begin_style_texi
+  $begin_special_region $simple_command $thing_command
   Also element formatting documentation, especially print_foot_navigation
   is not up to date.
   new arguments and return args of index_summary_letter

Index: texi2html.init
===================================================================
RCS file: /cvsroot/texi2html/texi2html/texi2html.init,v
retrieving revision 1.171
retrieving revision 1.172
diff -u -b -r1.171 -r1.172
--- texi2html.init      26 Nov 2008 19:09:01 -0000      1.171
+++ texi2html.init      27 Dec 2008 20:53:24 -0000      1.172
@@ -12,7 +12,7 @@
 # Afterwards, load the file with command-line 
 # option -init-file <your_init_file>
 #
-# $Id: texi2html.init,v 1.171 2008/11/26 19:09:01 pertusus Exp $
+# $Id: texi2html.init,v 1.172 2008/12/27 20:53:24 pertusus Exp $
 
 ######################################################################
 # The following variables can also be set by command-line options
@@ -1328,21 +1328,21 @@
     if (($user ne '') and ($date ne ''))
     {
         return  &$I('This document was generated by @emph{%{user}} on 
@emph{%{date}} using @uref{%{program_homepage}, @emph{%{program}}}.', {
-           'user' => $user, 'date' => $date, 'program_homepage' => 
$Texi2HTML::THISDOC{'program_homepage'}, 'program' => 
$Texi2HTML::THISDOC{'program'} });
+           'user' => $user, 'date' => $date, 'program_homepage' => 
$Texi2HTML::THISDOC{'program_homepage'}, 'program' => 
$Texi2HTML::THISDOC{'program'} }, {'duplicate'=>1});
     }
     elsif ($user ne '')
     {
         return  &$I('This document was generated by @emph{%{user}} using 
@uref{%{program_homepage}, @emph{%{program}}}.', {
-           'user' => $user, 'program_homepage' => 
$Texi2HTML::THISDOC{'program_homepage'}, 'program' => 
$Texi2HTML::THISDOC{'program'} });
+           'user' => $user, 'program_homepage' => 
$Texi2HTML::THISDOC{'program_homepage'}, 'program' => 
$Texi2HTML::THISDOC{'program'} }, {'duplicate'=>1});
     }
     elsif ($date ne '')
     {
         return  &$I('This document was generated on @i{%{date}} using 
@uref{%{program_homepage}, @i{%{program}}}.', {
-           'date' => $date, 'program_homepage' => 
$Texi2HTML::THISDOC{'program_homepage'}, 'program' => 
$Texi2HTML::THISDOC{'program'} });
+           'date' => $date, 'program_homepage' => 
$Texi2HTML::THISDOC{'program_homepage'}, 'program' => 
$Texi2HTML::THISDOC{'program'} },{'duplicate'=>1});
     }
     return &$I('This document was generated using @uref{%{program_homepage}, 
@emph{%{program}}}.', {
        'program_homepage' => $Texi2HTML::THISDOC{'program_homepage'}, 'program'
-=> $Texi2HTML::THISDOC{'program'} });
+=> $Texi2HTML::THISDOC{'program'} },{'duplicate'=>1});
 }
 
 sub T2H_DEFAULT_end_section($$$)
@@ -3888,7 +3888,7 @@
 $style_map_texi{'click'}->{'function'} = \&t2h_default_click_texi;
 
 ####### special styles. You shouldn't need to change them
-my %special_style = (
+%special_style = (
            #'xref'      => ['keep','normal','normal','keep','normal'],
            'xref'         => { 'args' => ['keep','keep','keep','keep','keep'],
                'function' => \&main::do_xref },
@@ -4416,6 +4416,8 @@
 $tab_item_texi              = \&t2h_default_tab_item_texi;
 $insertcopying              = \&t2h_default_insertcopying;
 $colon_command              = \&t2h_default_colon_command;
+$simple_command             = \&t2h_default_simple_command;
+$thing_command              = \&t2h_default_thing_command;
 
 # return the line after preserving things according to misc_command map.
 # You should not change it. It is here, nevertheless, to be used
@@ -4496,6 +4498,43 @@
     return ($line, $text, $args);
 }
 
+sub t2h_default_simple_command($$$$)
+{
+    my $command = shift;
+    my $in_preformatted = shift;
+    my $line_nr = shift;
+    my $state = shift;
+
+    if ($in_preformatted)
+    {
+        return $simple_map_pre{$command};
+    }
+    else
+    {
+        return $simple_map{$command};
+    }
+}
+
+sub t2h_default_thing_command($$$$$)
+{
+    my $command = shift;
+    my $text = shift;
+    my $in_preformatted = shift;
+    my $line_nr = shift;
+    my $state = shift;
+
+    my $result;
+    if ($in_preformatted)
+    {
+        $result = $pre_map{$command};
+    }
+    else 
+    {
+        $result = $things_map{$command};
+    }
+    return $result . $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 t2h_default_begin_format_texi($$$)
@@ -4806,7 +4845,7 @@
 }
 #
 #
-sub t2h_default_normal_text($$$$$$)
+sub t2h_default_normal_text($$$$$$;$)
 {
    my $text = shift;
    my $in_raw_text = shift; # remove_texi
@@ -4814,6 +4853,7 @@
    my $in_code = shift;
    my $in_simple = shift;
    my $style_stack = shift;
+   my $state = shift;
    $text = uc($text) if (in_cmd($style_stack, 'sc'));
    $text = &$protect_text($text) unless($in_raw_text);
    if (! $in_code and !$in_preformatted)
@@ -5341,51 +5381,51 @@
     {
          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 }) if ($section ne '');
-              return &$I('see %{node_file_href} @cite{%{book}}', { 
'node_file_href' => $file_node, 'book' => $book });
+              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 }) if ($section ne '');
-              return &$I('see @cite{%{book}}', { 'book' => $book });
+              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 });
+              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 }) if ($section ne '');
-              return &$I('See %{node_file_href} @cite{%{book}}', { 
'node_file_href' => $file_node, 'book' => $book });
+              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 }) if ($section ne '');
-              return &$I('See @cite{%{book}}', { 'book' => $book });
+              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 });
+              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 }) if ($section ne '');
-              return &$I('%{node_file_href} @cite{%{book}}', { 
'node_file_href' => $file_node, 'book' => $book });
+              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 }) if ($section ne '');
-              return &$I('@cite{%{book}}', { 'book' => $book });
+              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 
});
+              return &$I('%{node_file_href}', { 'node_file_href' => $file_node 
},{'duplicate'=>1});
          }
     }
     return '';
@@ -5419,17 +5459,17 @@
         $name = &$anchor('', $href, $name);
         if ($type eq 'pxref')
         {
-            return &$I('see section %{reference_name}', { 'reference_name' => 
$name }) if ($is_section);
-            return &$I('see %{reference_name}', { 'reference_name' => $name });
+            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 }) if ($is_section);
-            return &$I('See %{reference_name}', { 'reference_name' => $name });
+            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 });
+            return &$I('%{reference_name}', { 'reference_name' => $name 
},{'duplicate'=>1});
         }
     }
     else
@@ -5437,15 +5477,15 @@
         $name = &$anchor('', $href, $short_name);
         if ($type eq 'pxref')
         {
-            return &$I('see %{reference_name}', { 'reference_name' => $name });
+            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 });
+            return &$I('See %{reference_name}', { 'reference_name' => $name 
},{'duplicate'=>1});
         }
         elsif ($type eq 'ref')
         {
-            return &$I('%{reference_name}', { 'reference_name' => $name });
+            return &$I('%{reference_name}', { 'reference_name' => $name 
},{'duplicate'=>1});
         }
     }
     return '';
@@ -6346,7 +6386,7 @@
     }
     if ($with_explanation)
     {
-        return &$I('%{acronym_like} (%{explanation})', {'acronym_like' => 
$opening . $acronym_text . "</$attribute>", 'explanation' => $explanation_text})
+        return &$I('%{acronym_like} (%{explanation})', {'acronym_like' => 
$opening . $acronym_text . "</$attribute>", 'explanation' => 
$explanation_text},{'duplicate'=>1})
     }
     else
     {
@@ -6563,10 +6603,11 @@
     return &$anchor($id) . "\n";
 }
 
-sub t2h_default_anchor_label($$)
+sub t2h_default_anchor_label($$$)
 {
     my $id = shift;
     my $anchor_text = shift;
+    my $anchor_reference = shift;
     return &$anchor($id);
 }
 

Index: texi2html.pl
===================================================================
RCS file: /cvsroot/texi2html/texi2html/texi2html.pl,v
retrieving revision 1.251
retrieving revision 1.252
diff -u -b -r1.251 -r1.252
--- texi2html.pl        23 Dec 2008 14:02:24 -0000      1.251
+++ texi2html.pl        27 Dec 2008 20:53:24 -0000      1.252
@@ -74,7 +74,7 @@
 }
 
 # CVS version:
-# $Id: texi2html.pl,v 1.251 2008/12/23 14:02:24 pertusus Exp $
+# $Id: texi2html.pl,v 1.252 2008/12/27 20:53:24 pertusus Exp $
 
 # Homepage:
 my $T2H_HOMEPAGE = "http://www.nongnu.org/texi2html/";;
@@ -486,6 +486,9 @@
 $begin_paragraph_texi
 $tab_item_texi
 $colon_command
+$simple_command
+$thing_command
+$begin_special_region
 
 $PRE_ABOUT
 $AFTER_ABOUT
@@ -547,6 +550,7 @@
 @command_handler_process
 @command_handler_finish
 %command_handler
+%special_style
 );
 
 # subject to change
@@ -1710,8 +1714,8 @@
 {
    my $macro = shift;
    my $value = shift;
-   $Texi2HTML::Config::no_pagraph_commands{$macro} = $value 
-      unless defined($Texi2HTML::Config::no_pagraph_commands{$macro});
+   $Texi2HTML::Config::no_paragraph_commands{$macro} = $value 
+      unless defined($Texi2HTML::Config::no_paragraph_commands{$macro});
 }
 
 # those macros aren't considered as beginning a paragraph
@@ -7236,14 +7240,14 @@
     #
 
     #my $FH;
-    my $index_pages;
-    my $index_pages_nr;
     my $line_nr;
     my $current_file;
     my $first_section = 0; # 1 if it is the first section of a page
     my $previous_is_top = 0; # 1 if it is the element following the top element
 
     my $cline;
+    # this is true for the state that goes through the document
+    $state{'inside_document'} = 1;
     while (@$doc_lines)
     {
         $cline = shift @$doc_lines;
@@ -7257,13 +7261,14 @@
         #print STDERR 
"$line_nr->{'file_name'}($line_nr->{'macro'},$line_nr->{'line_nr'}) $cline" if 
($line_nr);
        #print STDERR "PASS_TEXT: $cline";
        #dump_stack(\$text, address@hidden, \%state);
+
         # make sure the current state from here is $Texi2HTML::THIS_ELEMENT
         # in case it was set by the user.
         $state{'element'} = $Texi2HTML::THIS_ELEMENT if 
(defined($Texi2HTML::THIS_ELEMENT));
         if (!$state{'raw'} and !$state{'verb'})
         {
             my $tag = '';
-            $tag = $1 if ($cline =~ /^\@(\w+)/ and !$index_pages);
+            $tag = $1 if ($cline =~ /^\@(\w+)/);
             if ($tag eq 'setfilename' and 
$Texi2HTML::Config::IGNORE_BEFORE_SETFILENAME)
             {
                 @{$Texi2HTML::THIS_SECTION} = ();
@@ -8145,7 +8150,7 @@
     {
         print STDERR "Bug: unknown anchor `$anchor'\n";
     }
-    return &$Texi2HTML::Config::anchor_label($nodes{$anchor}->{'id'}, $anchor);
+    return &$Texi2HTML::Config::anchor_label($nodes{$anchor}->{'id'}, $anchor, 
$nodes{$anchor});
 }
 
 sub get_format_command($)
@@ -8317,9 +8322,9 @@
 {
     my $line = shift;
     my $next_tag = next_tag($line);
-    return 1 if (($line =~ /^\s*$/) or 
$Texi2HTML::Config::no_pagraph_commands{$next_tag} or 
-       ($Texi2HTML::Config::no_pagraph_commands{'cindex'} and 
(index_command_prefix($next_tag) ne '')) or 
-       (($line =~ /address@hidden(\w+)/) and  
$Texi2HTML::Config::no_pagraph_commands{"end $1"}));
+    return 1 if (($line =~ /^\s*$/) or 
$Texi2HTML::Config::no_paragraph_commands{$next_tag} or 
+       ($Texi2HTML::Config::no_paragraph_commands{'cindex'} and 
(index_command_prefix($next_tag) ne '')) or 
+       (($line =~ /address@hidden(\w+)/) and  
$Texi2HTML::Config::no_paragraph_commands{"end $1"}));
     return 0;
 }
 
@@ -8505,6 +8510,8 @@
     {
         $new_state->{$key} = $region_initial_state{$region}->{$key};
     }
+    
&$Texi2HTML::Config::begin_special_region($region,$new_state,$region_lines{$region})
+      if (defined($Texi2HTML::Config::begin_special_region));
     my $text = substitute_text($new_state, undef, @{$region_lines{$region}});
 
     $region_initial_state{$region}->{'region_pass'}++;
@@ -8515,6 +8522,9 @@
     {
         $remove_texi_state->{$key} = $region_initial_state{$region}->{$key};
     }
+    
&$Texi2HTML::Config::begin_special_region($region,$remove_texi_state,$region_lines{$region})
+      if (defined($Texi2HTML::Config::begin_special_region));
+    print STDERR "# remove texi\n" if ($T2H_DEBUG);
     my $removed_texi = substitute_text($remove_texi_state, undef, 
@{$region_lines{$region}});
     $region_initial_state{$region}->{'region_pass'}++;
 
@@ -8523,6 +8533,10 @@
     {
         $simple_format_state->{$key} = $region_initial_state{$region}->{$key};
     }
+    
+    
&$Texi2HTML::Config::begin_special_region($region,$simple_format_state,$region_lines{$region})
+      if (defined($Texi2HTML::Config::begin_special_region));
+    print STDERR "# simple format\n" if ($T2H_DEBUG);
     my $simple_format = simple_format($simple_format_state, undef, 
@{$region_lines{$region}});
     $region_initial_state{$region}->{'region_pass'}++;
 
@@ -9362,7 +9376,7 @@
     {
         $preformatted_style = $state->{'preformatted_stack'}->[-1]->{'style'};
     }
-    return (&$Texi2HTML::Config::normal_text($text, $remove_texi, 
$preformatted_style, 
$state->{'code_style'},$state->{'simple_format'},$state->{'command_stack'}));
+    return (&$Texi2HTML::Config::normal_text($text, $remove_texi, 
$preformatted_style, 
$state->{'code_style'},$state->{'simple_format'},$state->{'command_stack'}, 
$state));
 }
 
 sub end_simple_format($$$)
@@ -10026,6 +10040,7 @@
          'region' => $state->{'region'},
          'sec_num' => $state->{'sec_num'},
          'outside_document' => $state->{'outside_document'},
+         'inside_document' => $state->{'inside_document'}
     };
     return $new_state;
 }
@@ -12145,14 +12160,17 @@
                 push (@$stack, { 'style' => $macro, 'text' => '', 'arg_nr' => 
0 });
                 $state->{'no_paragraph'}++ if ($no_paragraph_macro{$macro});
                 open_arg($macro, 0, $state);
+                my $real_style_command = 0;
                 if (defined($style_type{$macro}) and (($style_type{$macro} eq 
'style') or ($style_type{$macro} eq 'accent')))
                 {
                      push (@{$state->{'command_stack'}}, $macro);
+                     $real_style_command = 1;
                      #print STDERR "# Stacked $macro 
(@{$state->{'command_stack'}})\n" if ($T2H_DEBUG); 
                 }
                 # FIXME give line, and modify line?
-                &$Texi2HTML::Config::begin_style_texi($macro, $state, $stack)
-                  if (defined($Texi2HTML::Config::begin_style_texi));
+                &$Texi2HTML::Config::begin_style_texi($macro, $state, $stack, 
$real_style_command)
+                  if (defined($Texi2HTML::Config::begin_style_texi) 
+                      and !($state->{'keep_texi'} or $state->{'remove_texi'}));
                 next;
             }
 
@@ -12248,7 +12266,7 @@
             if ($simple_macro)
             {# if the macro didn't triggered a paragraph start it might now
                 begin_paragraph($stack, $state) if 
-                   ($Texi2HTML::Config::no_pagraph_commands{$macro} and 
!no_paragraph($state,$cline));
+                   ($Texi2HTML::Config::no_paragraph_commands{$macro} and 
!no_paragraph($state,$cline));
                 next;
             }
             # the following macros are modified or ignored if we are 
@@ -12538,7 +12556,7 @@
                     $state->{'no_paragraph'}--;
                     return;
                 }
-                elsif ($Texi2HTML::Config::no_pagraph_commands{$command} 
+                elsif ($Texi2HTML::Config::no_paragraph_commands{$command} 
                   and !$state->{'keep_texi'} and !no_paragraph($state,$cline))
                 {
                    begin_paragraph($stack, $state);
@@ -13022,13 +13040,9 @@
 #print STDERR "DO_SIMPLE remove_texi $macro\n";
             return  $::simple_map_texi_ref->{$macro};
         }
-        elsif ($state->{'preformatted'})
-        {
-            return $::simple_map_pre_ref->{$macro};
-        }
         else
         {
-            return $::simple_map_ref->{$macro};
+            return &$Texi2HTML::Config::simple_command($macro, 
$state->{'preformatted'}, $line_nr, $state);
         }
     }
     if (defined($::things_map_ref->{$macro}))
@@ -13036,22 +13050,17 @@
         my $result;
         if ($state->{'keep_texi'})
         {
-            $result = "address@hidden" . '{}';
+            return  "address@hidden" . '{}'.$text;
         }
         elsif ($state->{'remove_texi'})
         {
-            $result =  $::texi_map_ref->{$macro};
+            return  $::texi_map_ref->{$macro}.$text;
 #print STDERR "DO_SIMPLE remove_texi texi_map $macro\n";
         }
-        elsif ($state->{'preformatted'})
-        {
-            $result = $::pre_map_ref->{$macro};
-        }
         else 
         {
-            $result = $::things_map_ref->{$macro};
+            return &$Texi2HTML::Config::thing_command($macro, $text, 
$state->{'preformatted'}, $line_nr, $state);
         }
-        return $result . $text;
     }
     elsif (defined($::style_map_ref->{$macro}))
     {

Index: examples/docbook.init
===================================================================
RCS file: /cvsroot/texi2html/texi2html/examples/docbook.init,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- examples/docbook.init       11 Nov 2008 00:52:25 -0000      1.14
+++ examples/docbook.init       27 Dec 2008 20:53:25 -0000      1.15
@@ -111,7 +111,8 @@
 
 delete $stop_paragraph_command{'titlefont'};
 
-$no_pagraph_commands{'anchor'} = 0;
+# FIXME
+#$no_paragraph_commands{'anchor'} = 0;
 
 # FIXME
 delete $special_accents{'ringaccent'};
@@ -221,8 +222,8 @@
 
 #delete $inter_item_commands{'cindex'};
 
-#$no_pagraph_commands{'cindex'} = 0;
-$no_pagraph_commands{'float'} = 0;
+#$no_paragraph_commands{'cindex'} = 0;
+$no_paragraph_commands{'float'} = 0;
 
 %docbook_complex_format = (
    'example' => 'screen',
@@ -734,15 +735,15 @@
             $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] });
+                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] });
+                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] });
+                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]);
@@ -771,11 +772,11 @@
             }
             elsif ($type eq 'pxref')
             {
-                return &$I('see %{title_ref}', {'title_ref' => 
docbook_add_id('link')." linkend=\"$link\">$title</link>"});
+                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>"});
+                return &$I('See %{title_ref}', {'title_ref' => 
docbook_add_id('link')." linkend=\"$link\">$title</link>"},{'duplicate'=>1});
             }
         }
     }

Index: examples/html32.init
===================================================================
RCS file: /cvsroot/texi2html/texi2html/examples/html32.init,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- examples/html32.init        8 Nov 2008 20:02:51 -0000       1.21
+++ examples/html32.init        27 Dec 2008 20:53:25 -0000      1.22
@@ -352,7 +352,7 @@
     
     if ($with_explanation)
     {
-        return &$I('%{acronym_like} (%{explanation})', {'acronym_like' => 
$acronym_text, 'explanation' => $explanation_text})
+        return &$I('%{acronym_like} (%{explanation})', {'acronym_like' => 
$acronym_text, 'explanation' => $explanation_text},{'duplicate'=>1})
     }
     else
     {

Index: examples/info.init
===================================================================
RCS file: /cvsroot/texi2html/texi2html/examples/info.init,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- examples/info.init  23 Dec 2008 10:55:30 -0000      1.4
+++ examples/info.init  27 Dec 2008 20:53:25 -0000      1.5
@@ -26,6 +26,8 @@
 
 use Data::Dumper;
 
+use strict;
+
 $USE_NODES = 1;
 $USE_SECTIONS = 0;
 @EXPAND = ('info');
@@ -38,6 +40,8 @@
 $SEPARATED_FOOTNOTES = 0;
 $INLINE_CONTENTS = 1;
 
+$no_paragraph_commands{'anchor'} = 1;
+
 %simple_map = %ascii_simple_map;
 %simple_map_pre = %simple_map;
 %simple_map_texi = %simple_map;
@@ -55,8 +59,7 @@
 
 foreach my $accent_command ('tieaccent', 'dotless', keys(%unicode_accents), 
keys(%accent_map))
 {
-     #$style_map{$accent_command} = { 'function' => \&t2h_roff_accent };
-     $style_map{$accent_command} = '&roff_accent';
+     $style_map{$accent_command} = { 'function' => \&t2h_ascii_accent };
 }
 
 foreach my $command (keys(%style_map))
@@ -141,7 +144,6 @@
 }
 
 
-my $default_style_reference = $style;
 $style = \&info_default_style;
 $print_page_head   = \&info_default_print_page_head;
 $copying_comment   = \&info_default_copying_comment;
@@ -157,12 +159,12 @@
 $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;
+$anchor_label          = \&info_default_anchor_label;
 
 
-sub info_default_count_bytes()
-{
-}
-
 sub info_default_copying_comment($$$$)
 {
     my $copying_lines = shift;
@@ -172,60 +174,372 @@
     return '' if ($copying_text eq '');
     return $copying_text;
 }
-my @all_stacks;
-my $info_default_top_stack = {};
-my $current_command = $info_default_top_stack;
+my @info_default_all_stacks;
+my $info_default_top_stack;
+my $info_default_current_command;
+my $info_default_offset_in_file;
+my @info_default_pending_tags;
+
+sub info_default_reset_stack()
+{
+    $info_default_top_stack = {};
+    $info_default_current_command = $info_default_top_stack;
+}
+
+sub info_default_iterator_next($$$)
+{
+   my $current_command = shift;
+   my $command_index = shift;
+   my $command_close = shift;
+   
+   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_process_content($)
+{
+   my $current_command = shift;
+   my $length = 0;
+   my $add;
+
+   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];
+
+      if ($close)
+      {
+          if ($content->{'end'})
+          {
+              $add= length($content->{'end'});
+              $info_default_offset_in_file += $add;
+              $length += $add;
+          }
+      }
+      else
+      {
+          if ($content->{'command'} and $content->{'command'} eq 'anchor')
+          {
+              $content->{'anchor_reference'}->{'info_offset'} = 
$info_default_offset_in_file;
+              push @info_default_pending_tags, $content->{'anchor_reference'};
+          }
+
+          if ($content->{'begin'})
+          {
+              $add = length($content->{'begin'});
+              $info_default_offset_in_file += $add;
+              $length += $add;
+          }
+          if ($content->{'length'})
+          {
+              $add = $content->{'length'};
+              $info_default_offset_in_file += $add;
+              $length += $add;
+          }
+      }
+      ($current, $index, $close) = info_default_iterator_next($current, 
$index, $close);
+   }
+   return $length;
+}
 
 sub info_default_open_command($$$$$)
 {
-   my $command_stack = shift;
+   my $state = shift;
    my $command = shift;
    my $no_close = shift;
    my $no_open = shift;
    my $line_nr = shift;
 
-   my $new_command = {'command' => $command, 'parent' => $current_command};
-   push @{$current_command->{'content'}}, $new_command;
-   $current_command = $new_command;
-   print STDERR "Opened $command ". 
Data::Dumper->Dump([$info_default_top_stack]);
+   my $index = 0;
+   # index in the parent content list
+   $index = scalar(@{$info_default_current_command->{'content'}}) 
+       if (defined($info_default_current_command->{'content'}));
+   my $new_command = {'command' => $command, 'parent' => 
$info_default_current_command, 'index_in_parent' => $index };
+   push @{$info_default_current_command->{'content'}}, $new_command;
+   $info_default_current_command = $new_command;
+   print STDERR "Opened $command ". 
+     "\n";
+#     Data::Dumper->Dump([$info_default_top_stack]);
 }
 
-sub info_default_close_command($$$$$)
+sub info_default_close_command($$$$$$$$)
 {
    my $command_stack = shift;
    my $command = shift;
    my $no_close = shift;
    my $no_open = shift;
    my $line_nr = shift;
+   my $begin = shift;
+   my $text = shift;
+   my $end = shift;
+
    $no_open = 0 if (!defined($no_open));
    $no_close = 0 if (!defined($no_close));
    #print STDERR "" . Data::Dumper->Dump([$current_command]);
-   print STDERR "Closing $command ". 
Data::Dumper->Dump([$info_default_top_stack]);
-   return if $no_close;
-   $current_command = $current_command->{'parent'};
+   print STDERR "Closing $command ".
+     "\n";
+   if ($command ne $info_default_current_command->{'command'})
+   {
+     print STDERR "Was waiting for  
$info_default_current_command->{'command'}\n";
+   }
+#     Data::Dumper->Dump([$info_default_top_stack]);
+   #return if $no_close;
+   $info_default_current_command->{'no_close'} = 1 if ($no_close);
+   $info_default_current_command->{'begin'} = $begin;
+   $info_default_current_command->{'text'} = $text;
+   $info_default_current_command->{'end'} = $end;
 
-   if (!defined($current_command->{'command'}))
+   $info_default_current_command = $info_default_current_command->{'parent'};
+
+   if (!defined($info_default_current_command->{'command'}))
    {
-      push @all_stacks, $info_default_top_stack;
-      $info_default_top_stack = {};
       print STDERR "Storing the stack\n";
+      push @info_default_all_stacks, $info_default_top_stack;
+      print STDERR "" . Data::Dumper->Dump([$info_default_top_stack]);
+      info_default_process_content($info_default_top_stack);
+# debugging
+#      print STDERR "Current location $info_default_offset_in_file\n";
+
+#      my ($current_command, $current_index, $close) = 
($info_default_top_stack,0,0);
+#      print STDERR "info_default_top_stack $info_default_top_stack\n";
+#      while(1)
+#      {
+#         ($current_command, $current_index, $close) = 
info_default_iterator_next($current_command, $current_index, $close);
+#         last if (!defined($current_command) or (!defined($current_index)));
+#         my $command = '';
+#         $command = $current_command->{'command'} if 
(defined($current_command->{'command'}));
+#         my $current_content = 
$current_command->{'content'}->[$current_index];
+#         my $content_command = '';
+#         $content_command = $current_content->{'command'} if 
(defined($current_content->{'command'}));
+#         my $length = '';
+#         $length = $current_content->{'length'} if 
(defined($current_content->{'length'}));
+#         my $close_txt = '';
+#         $close_txt = ', close' if ($close);
+#         print STDERR 
"-->$current_command($current_index)$close_txt=$command|$content_command|$length\n";
+#      }
+      info_default_reset_stack();
    }
 }
 
+sub info_default_store_text($$;$)
+{
+   my $state = shift;
+   my $text = shift;
+   my $command = shift;
+#   $state = $Texi2HTML::THISDOC{'state'} if (!defined($state));
+   my $len = length($text);
+   return if ((!$state->{'inside_document'} and !$state->{'outside_document'})
+       or ($len == 0));
+   print STDERR "Storing text($len) $text\n";
+   my $text_stored = {'text' => $text, 'length' => $len};
+   $text_stored->{'command'} = $command if (defined($command));
+   push @{$info_default_current_command->{'content'}}, $text_stored;
+}
+
+sub info_default_find_position($;$$)
+{
+   my $offset = shift;
+   my $start_command = shift;
+   my $start_index = shift;
+   $start_command = $info_default_current_command 
+       if (!defined($start_command));
+   $start_index = 0 if (!defined($start_index));
+   my ($current, $index, $close) = ($start_command, $start_index, 0);
+   my $position = 0;
+
+   while(1)
+   {
+      last if (!defined($current));
+      my $content = $current->{'content'}->[$index];
+      my $last_position = $position;
+      if ($close)
+      {
+          if ($content->{'end'})
+          {
+              $position += length($content->{'end'});
+          }
+      }
+      else
+      {
+          if ($content->{'begin'})
+          {
+              $position += length($content->{'begin'});
+          }
+          if ($content->{'length'})
+          {
+              $position += $content->{'length'};
+          }
+      }
+      return ($current, $index, $close, $last_position) if ($position > 
$offset);
+      ($current, $index, $close) = info_default_iterator_next($current, 
$index, $close);
+   }
+   return (undef,undef,undef,undef);
+}
+
+sub info_default_remove_middle($$$)
+{
+   my $string = shift;
+   my $preserved_count = shift;
+   my $to_remove = shift;
+
+   if ($preserved_count > length($string))
+   {
+      $preserved_count -= length($string);
+      return ($string, $preserved_count, $to_remove);
+   }
+
+   my $begin = substr($string, 0, $preserved_count);
+   my $last_part = substr($string, $preserved_count);
+   $preserved_count = 0;
+   my $end = '';
+   if ($to_remove > length($last_part))
+   {
+       $to_remove -= length($last_part)
+   }
+   else
+   {
+       $end = substr($last_part, $to_remove);
+       $to_remove = 0;
+   }
+   return ($begin.$end, $preserved_count, $to_remove);
+}
+
+sub info_default_middle_insert($$$)
+{
+   my $string = shift;
+   my $preserved_count = shift;
+   my $inserted_string = shift;
+
+   if ($preserved_count > length($string))
+   {
+       return ($string,$preserved_count);
+   }
+   return (substr($string,0,$preserved_count) .$inserted_string.
+             substr($string, $preserved_count, 0));
+}
+
+sub info_default_add_string($$;$$)
+{
+   my $offset = shift;
+   my $string = shift;
+   my $start_command = shift;
+   my $start_index = shift;
+   $start_command = $info_default_current_command 
+       if (!defined($start_command));
+   $start_index = 0 if (!defined($start_index));
+   my ($current, $index, $close, $last_position) = 
+       info_default_find_position($offset, $start_command, $start_index);
+   return undef if (!defined($last_position));
+   my $preserved_count = $offset - $last_position;
+   my $content = $current->{'content'}->[$index];
+   my $text = '';
+   $text = $content->{'text'} if defined($content->{'text'});
+print STDERR "Add `$string' at $offset close: $close, preserved_count: 
$preserved_count, text `$text'\n";
+   if ($close)
+   {
+       ($content->{'end'}, $preserved_count) = 
+         info_default_middle_insert($content->{'end'}, $preserved_count, 
$string);
+   }
+   else
+   {
+      if (defined($content->{'begin'}))
+      { 
+          ($content->{'begin'}, $preserved_count) = 
+             info_default_middle_insert($content->{'begin'}, $preserved_count, 
$string)
+      }
+      if ($preserved_count and defined($content->{'text'}))
+      {
+          ($content->{'text'}, $preserved_count) = 
+             info_default_middle_insert($content->{'text'}, $preserved_count, 
$string);
+          if (defined($content->{'length'}))
+          {
+              $content->{'length'} = length($content->{'text'});
+          }
+      }
+   }
+   return $preserved_count;
+}
+
+sub info_default_remove_length($$;$$)
+{
+   my $offset = shift;
+   my $to_remove = shift;
+   my $start_command = shift;
+   my $start_index = shift;
+   return 0 if ($to_remove == 0);
+   $start_command = $info_default_current_command 
+       if (!defined($start_command));
+   $start_index = 0 if (!defined($start_index));
+   my ($current, $index, $close, $last_position) = 
+       info_default_find_position($offset, $start_command, $start_index);
+   return undef if (!defined($last_position));
+   my $preserved_count = $offset - $last_position;
+   while ($to_remove > 0)
+   {
+      my $content = $current->{'content'}->[$index];
+      if ($close)
+      {
+          ($content->{'end'}, $preserved_count, $to_remove) = 
+            info_default_remove_middle($content->{'end'}, $preserved_count, 
$to_remove)
+      }
+      else
+      {
+          if (defined($content->{'begin'}))
+          { 
+              ($content->{'begin'}, $preserved_count, $to_remove) = 
+                info_default_remove_middle($content->{'begin'}, 
$preserved_count, $to_remove)
+          }
+          if (defined($content->{'text'}))
+          { 
+              ($content->{'text'}, $preserved_count, $to_remove) = 
+                info_default_remove_middle($content->{'text'}, 
$preserved_count, $to_remove);
+              if (defined($content->{'length'}))
+              {
+                   $content->{'length'} = length($content->{'text'});
+              }
+          }
+      }
+      ($current, $index, $close) = info_default_iterator_next($current, 
$index, $close);
+   }
+   return $to_remove;
+}
+
 sub info_default_begin_format_texi($$$)
 {
    my $command = shift;
-   my $line = shit;
+   my $line = shift;
    my $state = shift;
-   info_default_open_command(undef,$command, undef, undef, undef);
+   info_default_open_command($state,$command, undef, undef, undef);
 }
 
-sub info_default_begin_style_texi($$$)
+sub info_default_begin_style_texi($$$$)
 {
    my $command = shift;
    my $state = shift;
    my $stack = shift;
-   info_default_open_command(undef,$command, undef, undef, undef);
+   my $real_style_command = shift;
+   info_default_open_command($state,$command, undef, undef, undef);
+#      if ($real_style_command);
 }
 
 sub info_default_begin_paragraph_texi($$$)
@@ -233,14 +547,47 @@
    my $command = shift;
    my $paragraph_macros = shift;
    my $paragraph_command = shift;
+   print STDERR "paragraph_command $paragraph_command\n";
    my $state = shift;
    my $stack = shift;
-   info_default_open_command(undef,$command, undef, undef, undef);
+   info_default_open_command($state,$command, undef, undef, undef);
+   foreach my $style_command (@$paragraph_macros)
+   {
+     print STDERR "para stack: $style_command->{'style'}\n";
+     info_default_open_command($state,$style_command->{'style'}, undef, undef, 
undef);
+     $info_default_current_command->{'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};
+    info_default_store_text($state,$result,$command);
+    return $result;
+}
+
+
+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};
+    info_default_close_command(undef, $command, undef, undef, $line_nr, 
$result, $text, '');
+    return $result . $text;
 }
 
+
 sub info_default_style($$$$$$$$$)
 {
-   my @orig_args = @_;
    my $style = shift; 
    my $command = shift;
    my $text = shift;
@@ -251,24 +598,25 @@
    my $state = shift;
    my $command_stack = shift;
 
+   my $begin = '';
+   my $end = '';
+
    if (defined($style->{'function'}))
    {
       $text = &{$style->{'function'}}($command, $args, $command_stack, $state, 
$line_nr);
    }
    if (defined($style->{'begin'}) and !$no_open)
    {
-      $text = $style->{'begin'} . $text;
+      $begin = $style->{'begin'};
    }
    if (defined($style->{'end'}) and !$no_close)
    {
-      $text = $text . $style->{'end'};
+      $end = $style->{'end'};
    }
-   info_default_close_command($command_stack, $command, $no_close, $no_open, 
$line_nr);
-   return $text;
+   info_default_close_command($command_stack, $command, $no_close, $no_open, 
$line_nr, $begin, $text, $end) unless($state->{'remove_texi'} or 
$special_style{$command});
+   return $begin.$text.$end;
 }
 
-my $info_default_offset_in_file;
-my @info_default_pending_tags;
 sub info_default_print_page_head($)
 {
     my $fh = shift;
@@ -279,6 +627,7 @@
     $result .= "$Texi2HTML::THISDOC{'copying_comment'}";
     $info_default_offset_in_file = length($result);
     @info_default_pending_tags = ();
+    info_default_reset_stack();
     print $fh $result;
 }
 
@@ -302,35 +651,54 @@
     my $command_stack_at_end = shift;
     my $command_stack_at_begin = shift;
 
-    my $para = '';
-    $text =~ /\s*$/;
-
+    my $begin_para = '';
+    # FIXME here may remove characters in front of the paragraph
+    if ($text =~ s/^(\s*)//)
+    {
+        info_default_remove_length(0,length($1));
+    }
     if ($info_default_paragraph_in_element_nr)
     {
         # add length(para) before
-        $para = ' ' x $info_default_para_indent_length;
+        $begin_para = ' ' x $info_default_para_indent_length;
     }
+    my $para = '';
     $info_default_paragraph_in_element_nr++;
 
-    my @lines = split (/\n/, $text);
-    my $line_char_counter = length($para);
+    my @lines = split (/^/, $text);
+    my $line_char_counter = length($begin_para);
     my $prev_space = '';
     while (@lines)
     {
        my $line = shift (@lines);
-       # here may remove characters in front of the line
-       $line =~ s/^\s*//;
-       # here may remove characters at the end of the line and replace
-       # with one space. Not sure it is correct 
-       $line =~ s/\s*$//;
-       $line .= ' ';
+       #$line .= "\n";
+       my $end_space = ' ';
+       if ($line =~ s/(\s*)$//)
+       {
+           print STDERR "Remove `$1' at ".(length($para) +length($line)).", 
".(length($para))."\n";
+           info_default_remove_length(length($para) +length($line), 
length($1));
+       }
+      print STDERR "BEFORE `$line' (".length($para).") " . 
Data::Dumper->Dump([$info_default_top_stack]);
+       info_default_add_string(length($para) +length($line), $end_space);
+      print STDERR "AFTER add at ".(length($para) +length($line))." 
`$end_space'  " . Data::Dumper->Dump([$info_default_top_stack]);
+       $line .= $end_space;
+       
        my ($word, $space);
-       while ($line =~ s/^([^\s]+)(\s*)//)
+#print STDERR "BEF $line\n";
+       while ($line =~ s/^(\s*[^\s]+)(\s*)//)
        {
           $word = $1;
           $space = $2;
-          if ($line_char_counter + length($word) > $info_default_max_column)
+#print STDERR "IN($line_char_counter,".length($word)."|$word) $line\n";
+          if ($line_char_counter + length($prev_space) + length($word) > 
$info_default_max_column)
+          {
+             # FIXME remove some spaces here
+             if (length($prev_space) > $info_default_max_column - 
$line_char_counter +1)
           {
+                 info_default_remove_length(length($para), 
$info_default_max_column - length($para));
+                 $word = substr($prev_space, $info_default_max_column - 
$line_char_counter +1) . $word;
+             }
+             info_default_add_string(length($para), "\n");
              $para .= "\n";
              $line_char_counter = 0;
           }
@@ -347,12 +715,14 @@
 #print STDERR "LAST $word\n";
        if ($word =~ /$info_default_end_sentence_character$/ and 
(scalar(@lines)))
        {
+          # FIXME add one space here
           $para .= ' ';
+          info_default_add_string(length($para), ' ');
           $line_char_counter += 1;
        }
     }
-    $para .=  "\n\n";
-    info_default_close_command(undef, 'paragraph', undef, undef, undef);
+    $para = $begin_para.$para. "\n\n";
+    info_default_close_command(undef, 'paragraph', undef, undef, undef, 
$begin_para, $para, "\n\n");
     return $para;
 }
 
@@ -388,8 +758,20 @@
     $element->{'info_offset'} = $info_default_offset_in_file;
     push @info_default_pending_tags, $element;
     my $result = "\x{1F}\nFile: $Texi2HTML::THIS_ELEMENT->{'file'},  Node: 
$element->{'text'}";
-    # here construct Next, Prev, Up
+    if (defined($Texi2HTML::THIS_ELEMENT->{'NodeNext'}))
+    {
+       $result .= ','.&$I('  Next: %{node_next}', {'node_next' => 
$Texi2HTML::THIS_ELEMENT->{'NodeNext'}->{'text'}});
+    }
+    if (defined($Texi2HTML::THIS_ELEMENT->{'NodePrev'}))
+    {
+       $result .= ','.&$I('  Prev: %{node_prev}', {'node_prev' => 
$Texi2HTML::THIS_ELEMENT->{'NodePrev'}->{'text'}});
+    }
+    if (defined($Texi2HTML::THIS_ELEMENT->{'NodeUp'}))
+    {
+       $result .= ','.&$I('  Up: %{node_up}', {'node_up' => 
$Texi2HTML::THIS_ELEMENT->{'NodeUp'}->{'text'}});
+    }
     $result .= "\n\n";
+    $info_default_offset_in_file += length($result);
     return $result;
 }
 
@@ -405,11 +787,13 @@
 
     die "Heading called for a node\n" if ($element->{'node'});
     $info_default_paragraph_in_element_nr = 0;
-    return "$element->{'text'}\n" . 
+    my $heading = "$element->{'text'}\n" . 
        ($default_info_level_to_symbol{$element->{'level'}} x 
length($element->{'text'})) . "\n\n";
+    $info_default_offset_in_file += length($heading);
+    return $heading;
 }
 
-sub  info_default_normal_text($$$$$$)
+sub info_default_normal_text($$$$$$;$)
 {
    my $text = shift;
    my $in_raw_text = shift; # remove_texi
@@ -417,6 +801,19 @@
    my $in_code = shift;
    my $in_simple = shift;
    my $style_stack = shift;
+   my $state = shift;
+
+#Data::Dumper->Dump([$state]);
+
+   # ignore text outside or paragraphs
+   if (($state->{'inside_document'} or $state->{'outside_document'}) and 
(!$in_raw_text) and (!$in_simple) and ($info_default_current_command eq 
$info_default_top_stack))
+   {
+       if ($text !~ /^\s*$/)
+       {
+           print STDERR "WARNING: ignoring non space text: $text\n";
+       }
+       return '';
+   }
    $text = uc($text) if (in_cmd($style_stack, 'sc'));
 #   $text = &$protect_text($text) unless($in_raw_text);
    if (! $in_code and !$in_preformatted)
@@ -434,6 +831,8 @@
 #       $text =~ s/'/\&rsquo\;/g unless ($special_code and 
exists($main::value{'txicodequoteundirected'}));
 #       $text =~ s/`/\&lsquo\;/g unless ($special_code and 
exists($main::value{'txicodequotebacktick'}));
    }
+   # We ignore the text outside paragraphs
+   info_default_store_text($state,$text) unless ($in_raw_text);
    return $text;
 }
 
@@ -446,6 +845,21 @@
     return '';
 }
 
+# change interface?
+sub info_default_anchor_label($$$)
+{
+    my $id = shift;
+    my $anchor_text = shift;
+    my $anchor_reference = shift;
+    # give it as an argument?
+    my $state = $Texi2HTML::THISDOC{'state'};
+    return if (!$state->{'inside_document'} and !$state->{'outside_document'});
+    print STDERR "Storing anchor $anchor_reference->{'text'}\n";
+    my $anchor_stored = {'command' => 'anchor', 'anchor_reference' => 
$anchor_reference};
+    push @{$info_default_current_command->{'content'}}, $anchor_stored;
+    return '';
+}
+
 sub info_default_acronym_like($$$$$$)
 {
     my $command = shift;
@@ -470,12 +884,14 @@
 sub info_default_print_page_foot($)
 {
    my $fh = shift;
-   print $fh "\x{1F}\nTag Table:\n";
+   # makeinfo seems to add systematically an additional \n, done just below
+   print $fh "\n\x{1F}\nTag Table:\n";
    # 
    foreach my $element (@info_default_pending_tags)
    {
       my $prefix;
       $prefix = 'Node' if ($element->{'node'});
+      $prefix = 'Ref' if ($element->{'anchor'});
       print $fh "$prefix: $element->{'text'}\x{7F}$element->{'info_offset'}\n";
    }
    print $fh "\x{1F}\nEnd Tag Table\n";
@@ -498,4 +914,17 @@
     &$print_page_foot($fh);
 }
 
+sub info_default_begin_special_region($$$)
+{
+    my $region = shift;
+    my $state = shift;
+    my $lines = shift;
+    if ($state->{'outside_document'})
+    {
+        $info_default_paragraph_in_element_nr = 0;
+        info_default_reset_stack();
+    }
+    
+}
+
 1;

Index: examples/xml.init
===================================================================
RCS file: /cvsroot/texi2html/texi2html/examples/xml.init,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- examples/xml.init   11 Nov 2008 00:52:25 -0000      1.11
+++ examples/xml.init   27 Dec 2008 20:53:25 -0000      1.12
@@ -157,7 +157,7 @@
 }
 
 
-$no_pagraph_commands{'cindex'} = 0;
+$no_paragraph_commands{'cindex'} = 0;
 
 #my @xml_ignored_misc_commands = ('bye', 'sp', 'verbatiminclude');
 
@@ -958,11 +958,11 @@
     my $result = '';
     if ($type eq 'pxref')
     {
-        $result = &$I('see ');
+        $result = &$I('see ',{'duplicate'=>1});
     }
     elsif ($type eq 'xref' or $type eq 'inforef')
     {
-        $result = &$I('See ');
+        $result = &$I('See ',{'duplicate'=>1});
     }
     if ($type eq 'inforef')
     {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]