[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: |
Sat, 02 Apr 2011 23:29:44 +0000 |
CVSROOT: /sources/texinfo
Module name: texinfo
Changes by: Patrice Dumas <pertusus> 11/04/02 23:29:44
Modified files:
tp/Texinfo/Convert: HTML.pm
Log message:
Handle @email.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/HTML.pm?cvsroot=texinfo&r1=1.2&r2=1.3
Patches:
Index: HTML.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/HTML.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- HTML.pm 28 Mar 2011 23:52:37 -0000 1.2
+++ HTML.pm 2 Apr 2011 23:29:43 -0000 1.3
@@ -39,11 +39,12 @@
# names by default without a very good reason. Use EXPORT_OK instead.
# Do not simply export all your public functions/methods/constants.
-# This allows declaration use Texinfo::Convert::Plaintext ':all';
+# This allows declaration use Texinfo::Convert::HTML ':all';
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
# will save memory.
%EXPORT_TAGS = ( 'all' => [ qw(
convert
+ convert_tree
output
) ] );
@@ -219,6 +220,10 @@
$css_map{"div.small$indented_format"} = 'margin-left: 3.2em';
}
+#Â default specification of arguments formatting
+my %default_commands_args = (
+ 'email' => [['code'], ['normal']]);
+
#Â Default for the function references used for the formatting
#Â of commands.
my %default_commands_conversion;
@@ -334,7 +339,7 @@
my $command = shift;
my $tree = $self->expand_today();
- return $self->_convert($tree);
+ return $self->convert_tree($tree);
}
$default_commands_conversion{'today'} = \&convert_today;
@@ -401,7 +406,6 @@
delete $style_commands_formatting{'preformatted'}->{'sc'}->{'attribute'};
delete $style_commands_formatting{'preformatted'}->{'sc'};
-# 'email', {'function' => \&html_default_email},
# 'key', {'begin' => '<', 'end' => '>'},
# 'uref', {'function' => \&html_default_uref},
# 'url', {'function' => \&html_default_uref},
@@ -454,6 +458,32 @@
return $text;
}
+sub expand_email($$$$)
+{
+ my $self = shift;
+ my $cmdname = shift;
+ my $command = shift;
+ my $args = shift;
+
+ my $mail_arg = shift @$args;
+ my $text_arg = shift @$args;
+ my $mail = '';
+ if (defined($mail_arg)) {
+ $mail = $mail_arg->{'code'};
+ }
+ # $mail = main::normalise_space($mail);
+ my $text = '';
+ if (defined($text_arg)) {
+ $text = $text_arg->{'normal'};
+ #Â $text = main::normalise_space($text);
+ }
+ $text = $mail unless ($text ne '');
+ return $text if ($mail eq '');
+ return "<a href=\"mailto:$mail\">$text</a>";
+}
+
+$default_commands_conversion{'email'} = \&expand_email;
+
sub accent_commands($$$$)
{
my $self = shift;
@@ -607,6 +637,14 @@
= $default_types_conversion{$type};
}
}
+ foreach my $command (keys %{$self->{'commands_conversion'}}) {
+ if (exists($Texinfo::Config::commands_args{$command})) {
+ $self->{'commands_args'}->{$command}
+ = $Texinfo::Config::commands_conversion{$command};
+ } elsif (exists($default_commands_args{$command})) {
+ $self->{'commands_args'}->{$command} = $default_commands_args{$command};
+ }
+ }
$self->{'context'} = [{'cmdname' => '_toplevel_context'}];
$self->{'formats'} = [];
@@ -635,6 +673,15 @@
return $result;
}
+#Â the entry point
+sub convert_tree($$)
+{
+ my $self = shift;
+ my $element = shift;
+
+ return $self->_convert($element);
+}
+
sub _normalized_to_id($)
{
my $id = shift;
@@ -1128,12 +1175,6 @@
my $cell;
my $preformatted;
if ($root->{'cmdname'}) {
- #Â TODO if w -> set protext_space
- # if code_style -> set it
- # if ($code_style_commands{$command});
- # if sc -> also in_upper_case
- #Â align command
- #Â preformatted
#Â FIXME definfoenclose_command
#Â ($root->{'type'} and $root->{'type'} eq 'definfoenclose_command'))
if (exists($self->{'commands_conversion'}->{$root->{'cmdname'}})) {
@@ -1176,8 +1217,24 @@
or ($root->{'cmdname'} eq 'float')) {
$args_formatted = [];
if ($root->{'args'}) {
+ my @args_specification;
+ @args_specification =
@{$self->{'commands_args'}->{$root->{'cmdname'}}}
+ if (defined($self->{'commands_args'}->{$root->{'cmdname'}}));
foreach my $arg (@{$root->{'args'}}) {
- push @$args_formatted, {'normal' => $self->_convert($arg)};
+ my $arg_spec = shift @args_specification;
+ $arg_spec = ['normal'] if (!defined($arg_spec));
+ my $arg_formatted = {'tree' => $arg};
+ foreach my $arg_type (@$arg_spec) {
+ if ($arg_type eq 'normal') {
+ $arg_formatted->{'normal'} = $self->_convert($arg);
+ } elsif ($arg_type eq 'code') {
+ $self->{'context'}->[-1]->{'code'}++;
+ $arg_formatted->{'code'} = $self->_convert($arg);
+ $self->{'context'}->[-1]->{'code'}--;
+ }
+ }
+
+ push @$args_formatted, $arg_formatted;
}
}
$result =
&{$self->{'commands_conversion'}->{$root->{'cmdname'}}}($self,
- texinfo/tp/Texinfo/Convert HTML.pm,
Patrice Dumas <=
- 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, 2011/04/13
- 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