[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
texinfo/tp/Texinfo/Convert HTML.pm
From: |
Patrice Dumas |
Subject: |
texinfo/tp/Texinfo/Convert HTML.pm |
Date: |
Wed, 13 Apr 2011 20:42:55 +0000 |
CVSROOT: /sources/texinfo
Module name: texinfo
Changes by: Patrice Dumas <pertusus> 11/04/13 20:42:54
Modified files:
tp/Texinfo/Convert: HTML.pm
Log message:
Add functions to get target information.
Use it to do root commands anchors.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/HTML.pm?cvsroot=texinfo&r1=1.19&r2=1.20
Patches:
Index: HTML.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/HTML.pm,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- HTML.pm 13 Apr 2011 20:14:29 -0000 1.19
+++ HTML.pm 13 Apr 2011 20:42:54 -0000 1.20
@@ -149,6 +149,55 @@
return $self->{'context'}->[-1]->{'align'}->[-1];
}
+sub command_id($$)
+{
+ my $self = shift;
+ my $command = shift;
+ if ($self->{'targets'}->{$command}) {
+ return $self->{'targets'}->{$command}->{'id'};
+ } else {
+ return undef;
+ }
+}
+
+sub command_target($$)
+{
+ my $self = shift;
+ my $command = shift;
+ if ($self->{'targets'}->{$command}) {
+ return $self->{'targets'}->{$command}->{'target'};
+ } else {
+ return undef;
+ }
+}
+
+sub command_filename($$)
+{
+ my $self = shift;
+ my $command = shift;
+
+ if ($self->{'targets'}->{$command}) {
+ my $target = $self->{'targets'}->{$command};
+ if (defined($target->{'filename'})) {
+ return $target->{'filename'};
+ }
+ my ($page, $element, $root_command) = $self->_get_page($command);
+ if (defined($element)) {
+ $target->{'element'} = $element;
+ }
+ if (defined($root_command)) {
+ $target->{'root_command'} = $root_command;
+ }
+ if (defined($page)) {
+ $target->{'page'} = $page;
+ $target->{'filename'} = $page->{'filename'};
+ return $target->{'filename'};
+ }
+ }
+ return undef;
+}
+
+# see http://www.w3.org/TR/REC-html40/types.html#type-links
# see http://www.w3.org/TR/REC-html40/types.html#type-links
my %BUTTONS_REL =
(
@@ -286,7 +335,9 @@
# default specification of arguments formatting
my %default_commands_args = (
- 'email' => [['code'], ['normal']]);
+ 'email' => [['code'], ['normal']],
+ 'anchor' => [['string']],
+);
# Default for the function references used for the formatting
# of commands.
@@ -629,8 +680,10 @@
#if ($self->{'TOC_LINKS'} and defined($element->{'tocid'})) {
# $text = &$anchor ('',
"$Texi2HTML::THISDOC{'toc_file'}#$element->{'tocid'}", $text);
#}
- my $heading = $args->[0]->{'normal'};
my $result = '';
+ my $element_id = $self->command_id($command);
+ $result .= "<a name=\"$element_id\"></a>\n" if ($element_id ne '');
+ my $heading = $args->[0]->{'normal'};
if ($heading ne '' and $do_heading) {
if ($self->in_preformatted()) {
$result .= '<strong>'.$heading.'</strong>'."\n";
@@ -1535,6 +1588,7 @@
'string' => 1,
'text' => 1,
'tree' => 1,
+ 'target' => 1,
);
sub _external_node_reference($$$;$)
@@ -1567,6 +1621,8 @@
my $command;
my $target;
+ $filename = $self->{'current_file'} if (!defined($filename));
+
if (!$valid_types{$type}) {
print STDERR "Incorrect type $type in _element_direction call\n";
return undef;
@@ -1598,6 +1654,9 @@
return $href;
} elsif (exists($target->{$type})) {
return $target->{$type};
+ } elsif ($type eq 'id' or $type eq 'target') {
+ # FIXME
+ return undef;
} elsif ($command) {
my $tree;
if (!$target->{'tree'}) {
@@ -1937,6 +1996,7 @@
}
#$self->{'fh'} = $fh;
}
+ $self->{'current_filename'} = $self->{'output_filename'};
my $header = begin_file($self, $self->{'output_filename'}, undef);
$output .= _output_text($header, $fh);
if ($elements and @$elements) {
@@ -1964,6 +2024,7 @@
# FIXME close/remove files already created
return undef;
}
+ $self->{'current_filename'} = $page->{'filename'};
print $file_fh "".begin_file($self, $page->{'filename'}, $page);
$files{$page->{'filename'}}->{'fh'} = $file_fh;
} else {
- texinfo/tp/Texinfo/Convert HTML.pm, Patrice Dumas, 2011/04/02
- texinfo/tp/Texinfo/Convert HTML.pm, Patrice Dumas, 2011/04/03
- texinfo/tp/Texinfo/Convert HTML.pm, Patrice Dumas, 2011/04/03
- texinfo/tp/Texinfo/Convert HTML.pm,
Patrice Dumas <=
- texinfo/tp/Texinfo/Convert HTML.pm, Patrice Dumas, 2011/04/14
- texinfo/tp/Texinfo/Convert HTML.pm, Patrice Dumas, 2011/04/17
- texinfo/tp/Texinfo/Convert HTML.pm, Patrice Dumas, 2011/04/17
- texinfo/tp/Texinfo/Convert HTML.pm, Patrice Dumas, 2011/04/18
- texinfo/tp/Texinfo/Convert HTML.pm, Patrice Dumas, 2011/04/24
- texinfo/tp/Texinfo/Convert HTML.pm, Patrice Dumas, 2011/04/25
- texinfo/tp/Texinfo/Convert HTML.pm, Patrice Dumas, 2011/04/29
- texinfo/tp/Texinfo/Convert HTML.pm, Patrice Dumas, 2011/04/30
- texinfo/tp/Texinfo/Convert HTML.pm, Patrice Dumas, 2011/04/30
- texinfo/tp/Texinfo/Convert HTML.pm, Patrice Dumas, 2011/04/30