[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
texinfo/tp/Texinfo Common.pm Structuring.pm Con...
From: |
Patrice Dumas |
Subject: |
texinfo/tp/Texinfo Common.pm Structuring.pm Con... |
Date: |
Sun, 05 Jun 2011 23:21:48 +0000 |
CVSROOT: /sources/texinfo
Module name: texinfo
Changes by: Patrice Dumas <pertusus> 11/06/05 23:21:48
Modified files:
tp/Texinfo : Common.pm Structuring.pm
tp/Texinfo/Convert: HTML.pm
Log message:
Find new command name for lowered or raised sections.
Don't split at node when splitting at chapter or section...
Handle sectioning commands without argument. Make sure that no <a >
element is output if the text or the name and href are empty.
Add a default filename for sections too, using the normalized
transliterated section name. Use it if NODE_FILENAMES is set.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Common.pm?cvsroot=texinfo&r1=1.46&r2=1.47
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Structuring.pm?cvsroot=texinfo&r1=1.61&r2=1.62
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/HTML.pm?cvsroot=texinfo&r1=1.86&r2=1.87
Patches:
Index: Common.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Common.pm,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -b -r1.46 -r1.47
--- Common.pm 4 Jun 2011 11:28:51 -0000 1.46
+++ Common.pm 5 Jun 2011 23:21:48 -0000 1.47
@@ -616,13 +616,38 @@
'appendixsubsubsec', 4,
);
+our %level_to_structuring_command;
+
+{
+ my $sections = [ ];
+ my $appendices = [ ];
+ my $unnumbered = [ ];
+ my $headings = [ ];
+ foreach my $command (keys (%command_structuring_level)) {
+ if ($command =~ /^appendix/) {
+ $level_to_structuring_command{$command} = $appendices;
+ } elsif ($command =~ /^unnumbered/ or $command eq 'top') {
+ $level_to_structuring_command{$command} = $unnumbered;
+ } elsif ($command =~ /section$/ or $command eq 'chapter') {
+ $level_to_structuring_command{$command} = $sections;
+ } else {
+ $level_to_structuring_command{$command} = $headings;
+ }
+
$level_to_structuring_command{$command}->[$command_structuring_level{$command}]
+ = $command;
+ }
+ $level_to_structuring_command{'appendixsection'} = $appendices;
+ $level_to_structuring_command{'majorheading'} = $headings;
+ $level_to_structuring_command{'centerchap'} = $unnumbered;
+}
+
+
# out of the main hierarchy
$command_structuring_level{'part'} = 0;
# this are synonyms
$command_structuring_level{'appendixsection'} = 2;
# command_structuring_level{'majorheading'} is also 1 and not 0
$command_structuring_level{'majorheading'} = 1;
-$command_structuring_level{'chapheading'} = 1;
$command_structuring_level{'centerchap'} = 1;
our %sectioning_commands;
Index: Structuring.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Structuring.pm,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -b -r1.61 -r1.62
--- Structuring.pm 4 Jun 2011 21:49:04 -0000 1.61
+++ Structuring.pm 5 Jun 2011 23:21:48 -0000 1.62
@@ -480,18 +480,15 @@
}
}
}
- # A bit of explanation about
!$node->{'node_up'}->{'extra'}->{'normalized'}:
- # it may happen (rarely) that the node_up has only a manual entry
- # and therefore !$node->{'node_up'}->{'extra'}->{'normalized'}
- # In that case there is always a {'manual_content'} and the condition
- # !$node->{'node_up'}->{'extra'}->{'manual_content'} is never set.
+ # it may happen (rarely) that the node_up is a manual entry
+ # and therefore $node->{'node_up'}->{'extra'}->{'manual_content'}
# The node_up should always be different from the menu_up, therefore
# if in a menu, the second condition/error message applies.
- if ($node->{'node_up'} and (!$node->{'menu_up_hash'}
- or !$node->{'node_up'}->{'extra'}->{'normalized'}
+ if ($node->{'node_up'} and
($node->{'node_up'}->{'extra'}->{'manual_content'}
+ or !$node->{'menu_up_hash'}
or
!$node->{'menu_up_hash'}->{$node->{'node_up'}->{'extra'}->{'normalized'}})) {
if (!$node->{'node_up'}->{'extra'}->{'manual_content'}) {
- # up node has no menu entry
+ # up node is a real node but has no menu entry
$self->line_error(sprintf($self->
__("Node `%s' lacks menu item for `%s' despite being its Up
target"),
_node_extra_to_texi($node->{'node_up'}->{'extra'}),
@@ -626,7 +623,8 @@
and $element->{'extra'}->{'node'}->{'associated_section'}) {
$level =
$element->{'extra'}->{'node'}->{'associated_section'}->{'level'};
}
- if ($split eq 'node' or (defined($level) and $split_level <= $level)
+ #print STDERR "level($split_level) $level
"._print_element_command_texi($element)."\n";
+ if ($split eq 'node' or (defined($level) and $split_level >= $level)
or address@hidden) {
push @pages, {'type' => 'page',
'extra' => {'element' => $element}};
Index: Convert/HTML.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/HTML.pm,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -b -r1.86 -r1.87
--- Convert/HTML.pm 5 Jun 2011 14:51:37 -0000 1.86
+++ Convert/HTML.pm 5 Jun 2011 23:21:48 -0000 1.87
@@ -426,6 +426,12 @@
'contents' => $command->{'extra'}->{'node_content'}};
} elsif ($command->{'cmdname'} and ($command->{'cmdname'} eq 'float')) {
$tree = $self->float_type_number($command);
+ } elsif ($command->{'extra'}->{'missing_argument'}) {
+ if ($type eq 'tree' or $type eq 'tree_nonumber') {
+ return {};
+ } else {
+ return '';
+ }
} else {
if (!$command->{'extra'}->{'misc_content'}) {
cluck "No misc_content: "
@@ -1269,7 +1275,7 @@
my $args = shift;
my $id = $self->command_id ($command);
- if (defined($id)) {
+ if (defined($id) and $id ne '') {
return "<a name=\"$id\"></a>";
}
return '';
@@ -1869,8 +1875,9 @@
}
my $result = '';
my $element_id = $self->command_id($command);
+ # FIXME a href here doesn't make sense, there is no text?
$result .= "<a name=\"$element_id\"${content_ref}></a>\n"
- if (defined($element_id));
+ if (defined($element_id) and $element_id ne '');
print STDERR "Process $command "
.Texinfo::Structuring::_print_root_command_texi($command)."\n"
@@ -1949,6 +1956,11 @@
if ($self->in_preformatted()) {
$result .= '<strong>'.$heading.'</strong>'."\n";
} else {
+ # if the level was changed, set the command name right
+ if ($heading_level ne
$Texinfo::Common::command_structuring_level{$cmdname}) {
+ $cmdname
+ =
$Texinfo::Common::level_to_structuring_command{$cmdname}->[$heading_level];
+ }
$result .= &{$self->{'heading_text'}}($self, $cmdname, $heading,
$heading_level, $command);
}
@@ -2253,7 +2265,7 @@
my $id = $self->command_id($command);
my $label;
- if ($id) {
+ if (defined($id) and $id ne '') {
$label = "<a name=\"$id\"></a>";
} else {
$label = '';
@@ -2471,7 +2483,7 @@
}
}
my $index_id = $self->command_id ($command);
- if (defined($index_id)) {
+ if (defined($index_id) and $index_id ne '') {
$result .= "\n<a name=\"$index_id\"></a>\n";
}
@@ -2702,7 +2714,7 @@
my $args = shift;
my $index_id = $self->command_id ($command);
- if (defined($index_id)) {
+ if (defined($index_id) and $index_id ne '') {
return "<a name=\"$index_id\"></a>\n";
}
return '';
@@ -2875,7 +2887,9 @@
my $special_element
= $self->special_element($contents_command_element_name{$cmdname});
my $id = $self->command_id($special_element);
+ if ($id ne '') {
$result .= "<a name=\"$id\"></a>\n";
+ }
my $heading = $self->command_text($special_element, 'text');
$result .= &{$self->{'heading_text'}}($self, $cmdname, $heading,
0)."\n";
$result .= $content . "\n";
@@ -3200,7 +3214,7 @@
#my $section_name = $self->command_text($section);
$name = $self->command_text($section);
$name_no_number = $self->command_text($section, 'text_nonumber');
- if ($href ne '') {
+ if ($href ne '' and $name ne '') {
#$name = "<a href=\"$href\"$accesskey>".$section_name."</a>";
$name = "<a href=\"$href\"$accesskey>".$name."</a>";
}# else {
@@ -3340,7 +3354,7 @@
my $index_label = '';
my $index_id = $self->command_id ($command);
- if (defined($index_id)) {
+ if (defined($index_id) and $index_id ne '') {
$index_label = "<a name=\"$index_id\"></a>";
}
if (!$self->get_conf('DEF_TABLE')) {
@@ -3479,7 +3493,9 @@
if ($element->{'extra'}->{'special_element'}) {
$special_element = $element->{'extra'}->{'special_element'};
my $id = $self->command_id($element);
+ if ($id ne '') {
$result .= "<a name=\"$id\"></a>\n";
+ }
if ($self->get_conf('HEADERS')
# first in page
or $element->{'parent'}->{'contents'}->[0] eq $element) {
@@ -3966,10 +3982,14 @@
$no_unidecode = 1 if (defined($self->get_conf('USE_UNIDECODE'))
and !$self->get_conf('USE_UNIDECODE'));
- my $target_base = _normalized_to_id(
- Texinfo::Convert::NodeNameNormalization::transliterate_texinfo(
+ my $filename =
Texinfo::Convert::NodeNameNormalization::transliterate_texinfo(
{'contents' => $command->{'extra'}->{'misc_content'}},
- $no_unidecode));
+ $no_unidecode);
+
+ my $target_base = _normalized_to_id($filename);
+ $filename .= '.'.$self->get_conf('EXTENSION')
+ if (defined($self->get_conf('EXTENSION'))
+ and $self->get_conf('EXTENSION') ne '');
if ($target_base !~ /\S/ and $command->{'cmdname'} eq 'top'
and defined($self->{'misc_elements_targets'}->{'Top'})) {
$target_base = $self->{'misc_elements_targets'}->{'Top'};
@@ -4039,7 +4059,7 @@
if (defined($Texinfo::Config::sectioning_command_target_name)) {
($target, $id, $target_contents, $id_contents,
- $target_shortcontents, $id_shortcontents)
+ $target_shortcontents, $id_shortcontents, $filename)
= &$Texinfo::Config::sectioning_command_target_name($self,
$command, $target, $id,
$target_contents, $id_contents,
@@ -4051,6 +4071,7 @@
$self->{'targets'}->{$command} = {
'target' => $target,
'id' => $id,
+ 'section_filename' => $filename,
};
# FIXME this should really be use carefully, since the mapping
# is not what one expects
@@ -4222,16 +4243,20 @@
$node_top = $self->{'labels'}->{'Top'} if ($self->{'labels'});
#$section_top = $self->{'extra'}->{'top'} if ($self->{'extra'});
+ my $top_node_filename;
+ if (defined($self->get_conf('TOP_NODE_FILE'))) {
+ $top_node_filename = $self->get_conf('TOP_NODE_FILE');
+ $top_node_filename .= '.'.$self->get_conf('NODE_FILE_EXTENSION')
+ if (defined($self->get_conf('NODE_FILE_EXTENSION'))
+ and $self->get_conf('NODE_FILE_EXTENSION') ne '');
+ }
# first determine the top node file name.
- if ($self->get_conf('NODE_FILENAMES') and $node_top) {
+ if ($self->get_conf('NODE_FILENAMES') and $node_top
+ and defined($top_node_filename)) {
my ($node_top_page) = $self->_get_page($node_top);
die "BUG: No page for top node" if (!defined($node_top));
if (defined($self->get_conf('TOP_NODE_FILE'))) {
- my $filename = $self->get_conf('TOP_NODE_FILE');
- $filename .= '.'.$self->get_conf('NODE_FILE_EXTENSION')
- if (defined($self->get_conf('NODE_FILE_EXTENSION'))
- and $self->get_conf('NODE_FILE_EXTENSION') ne '');
- $self->_set_page_file($node_top_page, $filename);
+ $self->_set_page_file($node_top_page, $top_node_filename);
}
}
# FIXME add a number for each page?
@@ -4257,11 +4282,28 @@
}
}
}
+ # use section to do the file name if there is no node
+ my $command;
+ foreach my $element (@{$page->{'contents'}}) {
+ $command = $self->element_command($element);
+ last if $command;
+ }
+ if ($command) {
+ if ($command->{'cmdname'} eq 'top' and !$node_top
+ and defined($top_node_filename)) {
+ $self->_set_page_file($page, $top_node_filename);
+ } else {
+ $self->_set_page_file($page,
+ $self->{'targets'}->{$command}->{'section_filename'});
+ }
+ } else {
+ # when everything else has failed
my $filename = $self->{'document_name'} . "_$file_nr";
$filename .= $extension;
$self->_set_page_file($page, $filename);
$file_nr++;
}
+ }
} else {
my $previous_page;
foreach my $page(@$pages) {
@@ -4870,7 +4912,19 @@
# no indenting for shortcontents
$result .= (' ' x (2*($section->{'level'} - $root_level)))
if ($contents);
- $result .= "<li><a name=\"$toc_id\" href=\"$href\">$text</a>";
+ if ($toc_id ne '' or $href ne '') {
+ my $toc_name_attribute = '';
+ if ($toc_id ne '') {
+ $toc_name_attribute = "name=\"$toc_id\" ";
+ }
+ my $href_attribute = '';
+ if ($href ne '') {
+ $href_attribute = "href=\"$href\"";
+ }
+ $result .= "<li><a
${toc_name_attribute}${href_attribute}>$text</a>";
+ } else {
+ $result .= "<li>$text";
+ }
}
}
# for shortcontents don't do child if child is not toplevel
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- texinfo/tp/Texinfo Common.pm Structuring.pm Con...,
Patrice Dumas <=