[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
texinfo/tp TODO texi2any.pl Texinfo/Parser.pm T...
From: |
Patrice Dumas |
Subject: |
texinfo/tp TODO texi2any.pl Texinfo/Parser.pm T... |
Date: |
Sun, 01 May 2011 22:24:54 +0000 |
CVSROOT: /sources/texinfo
Module name: texinfo
Changes by: Patrice Dumas <pertusus> 11/05/01 22:24:54
Modified files:
tp : TODO texi2any.pl
tp/Texinfo : Parser.pm
tp/Texinfo/Convert: HTML.pm
Log message:
Add a new type, preamble_before_setfilename to hold everything before
@setfilename.
As texi2html, ignore space only contents at the beginning.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/TODO?cvsroot=texinfo&r1=1.123&r2=1.124
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/texi2any.pl?cvsroot=texinfo&r1=1.38&r2=1.39
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Parser.pm?cvsroot=texinfo&r1=1.249&r2=1.250
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/HTML.pm?cvsroot=texinfo&r1=1.48&r2=1.49
Patches:
Index: TODO
===================================================================
RCS file: /sources/texinfo/texinfo/tp/TODO,v
retrieving revision 1.123
retrieving revision 1.124
diff -u -b -r1.123 -r1.124
--- TODO 1 May 2011 17:12:45 -0000 1.123
+++ TODO 1 May 2011 22:24:53 -0000 1.124
@@ -54,6 +54,9 @@
html tests which should be right:
sectioning setfilename_on_top_and_after_node
+Test tree leading to non empty preamble_before_setfilename. Currently there
+are none in the test suite, maye require a real file as input.
+
Handle
@xrefautomaticsectiontitle on|off
(does nothing in info, in HTML automatically set the section name as 3rd
Index: texi2any.pl
===================================================================
RCS file: /sources/texinfo/texinfo/tp/texi2any.pl,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -b -r1.38 -r1.39
--- texi2any.pl 1 May 2011 15:15:46 -0000 1.38
+++ texi2any.pl 1 May 2011 22:24:53 -0000 1.39
@@ -614,7 +614,8 @@
}
foreach my $parser_settable_option ('TOP_NODE_UP', 'MAX_MACRO_CALL_NESTING',
- 'INLINE_INSERTCOPYING', 'SHOW_MENU') {
+ 'INLINE_INSERTCOPYING', 'SHOW_MENU',
+ 'IGNORE_BEFORE_SETFILENAME') {
$parser_default_options->{$parser_settable_option} =
get_conf($parser_settable_option)
if (defined(get_conf($parser_settable_option)));
}
Index: Texinfo/Parser.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Parser.pm,v
retrieving revision 1.249
retrieving revision 1.250
diff -u -b -r1.249 -r1.250
--- Texinfo/Parser.pm 30 Apr 2011 17:34:47 -0000 1.249
+++ Texinfo/Parser.pm 1 May 2011 22:24:53 -0000 1.250
@@ -221,6 +221,7 @@
'expanded_formats' => [],
'include_directories' => [ '.' ],
'INLINE_INSERTCOPYING' => 0,
+ 'IGNORE_BEFORE_SETFILENAME' => 1,
# this is the initial context. It is put at the bottom of the
# 'context_stack'
'context' => '_root',
@@ -796,7 +797,36 @@
'fh' => $filehandle
}];
$self->{'info'}->{'input_file_name'} = $file_name;
- return $self->_parse_texi($root);
+ my $tree = $self->_parse_texi($root);
+
+ # if there are elements, 'text_root' is the first content, otherwise it
+ # is the root.
+ my $text_root;
+ if ($tree->{'type'} eq 'text_root') {
+ $text_root = $tree;
+ } elsif ($tree->{'contents'} and $tree->{'contents'}->[0]
+ and $tree->{'contents'}->[0]->{'type'} eq 'text_root') {
+ $text_root = $tree->{'contents'}->[0];
+ }
+
+ # Put everything before @setfilename in a special type. This allows to
+ # ignore everything before @setfilename.
+ if ($self->{'IGNORE_BEFORE_SETFILENAME'} and $text_root and
+ $self->{'extra'} and $self->{'extra'}->{'setfilename'}
+ and $self->{'extra'}->{'setfilename'}->{'parent'} eq $text_root) {
+ my $before_setfilename = {'type' => 'preamble_before_setfilename',
+ 'parent' => $text_root,
+ 'contents' => []};
+ while ($text_root->{'contents'}->[0] ne $self->{'extra'}->{'setfilename'})
{
+ my $content = shift @{$text_root->{'contents'}};
+ $content->{'parent'} = $before_setfilename;
+ push @{$before_setfilename->{'contents'}}, $content;
+ }
+ unshift (@{$text_root->{'contents'}}, $before_setfilename)
+ if (@{$before_setfilename->{'contents'}});
+ }
+
+ return $tree;
}
sub parse_texi_line($$;$)
Index: Texinfo/Convert/HTML.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/HTML.pm,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -b -r1.48 -r1.49
--- Texinfo/Convert/HTML.pm 1 May 2011 19:40:20 -0000 1.48
+++ Texinfo/Convert/HTML.pm 1 May 2011 22:24:54 -0000 1.49
@@ -1468,10 +1468,11 @@
my $heading_level;
# FIXME this is done as in texi2html: node is used as heading if there
- #Â is nothing else. Is it right?
+ # is nothing else. Is it right?
if ($cmdname eq 'node') {
- if (!$element->{'extra'}->{'section'}
- and $element->{'extra'}->{'node'} eq $command) {
+ if (!$element or (!$element->{'extra'}->{'section'}
+ and $element->{'extra'}->{'node'}
+ and $element->{'extra'}->{'node'} eq $command)) {
if ($command->{'extra'}->{'normalized'} eq 'Top') {
$heading_level = 0;
} else {
@@ -1544,7 +1545,11 @@
my $args = shift;
my $verbatim_include_verbatim = $self->expand_verbatiminclude($command);
+ if (defined($verbatim_include_verbatim)) {
return $self->convert_tree($verbatim_include_verbatim);
+ } else {
+ return '';
+ }
}
$default_commands_conversion{'verbatiminclude'}
@@ -1689,7 +1694,7 @@
foreach my $type ('empty_line_after_command', 'preamble',
'empty_spaces_after_command', 'spaces_at_end',
'empty_spaces_before_argument', 'empty_spaces_before_paragraph',
- 'empty_spaces_after_close_brace') {
+ 'empty_spaces_after_close_brace', 'preamble_before_setfilename') {
#$ignored_types{$type} = 1;
$default_types_conversion{$type} = undef;
}
@@ -2054,6 +2059,7 @@
my $content = shift;
my $result = $content;
+ #$result =~ s/^\s*//;
# if there is no element, the parent should not be an element
if (defined($self->get_conf('DEFAULT_RULE'))
and (!$command->{'parent'}->{'type'}
@@ -4421,8 +4427,21 @@
cluck "for $root contents not an array: $root->{'contents'}";
print STDERR Texinfo::Structuring::_print_current($root);
}
+
+ # FIXME as texi2html, ignore space only contents at the beginning.
+ # Is it right?
+ my $only_spaces;
+ if ($root->{'type'} eq 'text_root') {
+ $only_spaces = 1;
+ }
foreach my $content (@{$root->{'contents'}}) {
- $content_formatted .= $self->_convert($content);
+ my $new_content = $self->_convert($content);
+ if ($only_spaces) {
+ if ($new_content =~ /\S/) {
+ $only_spaces = 0;
+ }
+ }
+ $content_formatted .= $new_content unless ($only_spaces);
}
}
my $result = '';
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- texinfo/tp TODO texi2any.pl Texinfo/Parser.pm T...,
Patrice Dumas <=