[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
texinfo/tp Makefile.am Texinfo/Convert/HTML.pm ...
From: |
Patrice Dumas |
Subject: |
texinfo/tp Makefile.am Texinfo/Convert/HTML.pm ... |
Date: |
Sat, 08 Oct 2011 20:04:46 +0000 |
CVSROOT: /sources/texinfo
Module name: texinfo
Changes by: Patrice Dumas <pertusus> 11/10/08 20:04:46
Modified files:
tp : Makefile.am
tp/Texinfo/Convert: HTML.pm
Added files:
tp/init : html32.pm
Log message:
Add the html 3.2 customization init file.
Allow protect_text customization and export default types and commands
formatting.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Makefile.am?cvsroot=texinfo&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/HTML.pm?cvsroot=texinfo&r1=1.175&r2=1.176
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/init/html32.pm?cvsroot=texinfo&rev=1.1
Patches:
Index: Makefile.am
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Makefile.am,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- Makefile.am 1 Oct 2011 23:09:22 -0000 1.6
+++ Makefile.am 8 Oct 2011 20:04:45 -0000 1.7
@@ -57,6 +57,9 @@
DebugTexinfo/DebugCount.pm \
DebugTexinfo/DebugTree.pm
+initdir = $(datadir)/texinfo/init
+dist_init_DATA = init/html32.pm
+
test_files = \
t/27float.t \
t/test_count.t \
Index: Texinfo/Convert/HTML.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/HTML.pm,v
retrieving revision 1.175
retrieving revision 1.176
diff -u -b -r1.175 -r1.176
--- Texinfo/Convert/HTML.pm 8 Oct 2011 09:59:19 -0000 1.175
+++ Texinfo/Convert/HTML.pm 8 Oct 2011 20:04:45 -0000 1.176
@@ -1016,7 +1016,12 @@
# of commands.
my %default_commands_conversion;
-# Ignored commands
+sub default_commands_conversion($$)
+{
+ my $self = shift;
+ my $command = shift;
+ return $default_commands_conversion{$command};
+}
my %kept_misc_commands;
@@ -1552,7 +1557,7 @@
$alt_text = $args->[3]->{'normal'};
}
if (!defined($alt_text) or ($alt_text eq '')) {
- $alt_text = $self->xml_protect_text($basefile);
+ $alt_text = $self->protect_text($basefile);
}
return "[ $alt_text ]";
} else {
@@ -1561,9 +1566,9 @@
$alt_string = $args->[3]->{'string'};
}
if (!defined($alt_string) or ($alt_string eq '')) {
- $alt_string = $self->xml_protect_text($basefile);
+ $alt_string = $self->protect_text($basefile);
}
- return "<img src=\"".$self->xml_protect_text($image_file)."\"
alt=\"$alt_string\">";
+ return "<img src=\"".$self->protect_text($image_file)."\"
alt=\"$alt_string\">";
}
}
return '';
@@ -1611,7 +1616,7 @@
#print STDERR Texinfo::Parser::_print_current($command);
return '';
}
- return $self->xml_protect_text('<') .$text .$self->xml_protect_text('>');
+ return $self->protect_text('<') .$text .$self->protect_text('>');
}
$default_commands_conversion{'key'} = \&_convert_key_command;
@@ -1631,10 +1636,10 @@
return '';
}
if (!$self->in_string()) {
- return $self->xml_protect_text('<').'<code>' .$text
- .'</code>'.$self->xml_protect_text('>');
+ return $self->protect_text('<').'<code>' .$text
+ .'</code>'.$self->protect_text('>');
} else {
- return $self->xml_protect_text('<').$text.$self->xml_protect_text('>');
+ return $self->protect_text('<').$text.$self->protect_text('>');
}
}
@@ -1655,7 +1660,7 @@
#print STDERR Texinfo::Parser::_print_current($command);
return '';
}
- return $self->xml_protect_text('^') .$text;
+ return $self->protect_text('^') .$text;
}
$default_commands_conversion{'ctrl'} = \&_convert_ctrl_command;
@@ -1688,6 +1693,18 @@
return $self->xml_comment(' '.$text);
}
+sub protect_text($$) {
+ my $self = shift;
+ my $text = shift;
+ return &{$self->{'protect_text'}}($self, $text);
+}
+
+sub _default_protect_text($$) {
+ my $self = shift;
+ my $text = shift;
+ return $self->xml_protect_text($text);
+}
+
sub _default_heading_text($$$$$)
{
my $self = shift;
@@ -2183,14 +2200,14 @@
return $content;
# FIXME compatibility with texi2html
} elsif ($self->in_string()) {
- return $self->xml_protect_text($content);
+ return $self->protect_text($content);
} elsif ($cmdname eq 'tex') {
return $self->_attribute_class('pre', $cmdname).'>'
- .$self->xml_protect_text($content) . '</pre>';
+ .$self->protect_text($content) . '</pre>';
}
$self->line_warn(sprintf($self->__("Raw format %s is not converted"),
$cmdname),
$command->{'line_nr'});
- return $self->xml_protect_text($content);
+ return $self->protect_text($content);
}
foreach my $command (@out_formats) {
@@ -3096,7 +3113,7 @@
$letter_id{$letter} = $identifier;
my $summary_letter_link = $self->_attribute_class('a', 'summary-letter')
- ."
href=\"#$identifier\"><b>".$self->xml_protect_text($letter).'</b></a>';
+ ." href=\"#$identifier\"><b>".$self->protect_text($letter).'</b></a>';
if ($is_symbol) {
push @non_alpha, $summary_letter_link;
} else {
@@ -3190,7 +3207,7 @@
}
# a letter and associated indice entries
$result .= '<tr><th>' .
- "<a name=\"$letter_id{$letter}\">".$self->xml_protect_text($letter).'</a>'
+ "<a name=\"$letter_id{$letter}\">".$self->protect_text($letter).'</a>'
. "</th><td></td><td></td></tr>\n" . $entries_text .
"<tr><td colspan=\"4\">
".$self->get_conf('DEFAULT_RULE')."</td></tr>\n";
@@ -3266,6 +3283,15 @@
my %default_types_conversion;
+sub default_types_conversion($$)
+{
+ my $self = shift;
+ my $type = shift;
+ return $default_types_conversion{$type};
+}
+
+# Ignored commands
+
#my %ignored_types;
foreach my $type ('empty_line_after_command', 'preamble',
'preamble_before_setfilename',
@@ -3443,8 +3469,8 @@
my $command = shift;
my $content = shift;
- return $self->xml_protect_text($command->{'extra'}->{'begin'}) . $content
- .$self->xml_protect_text($command->{'extra'}->{'end'});
+ return $self->protect_text($command->{'extra'}->{'begin'}) . $content
+ .$self->protect_text($command->{'extra'}->{'end'});
}
$default_types_conversion{'definfoenclose_command'}
@@ -3459,11 +3485,11 @@
# do that first because in verb and verbatim, type is 'raw'
if ($self->in_verbatim()) {
- return $self->xml_protect_text($text);
+ return $self->protect_text($text);
}
return $text if ($type and $type eq 'raw');
$text = uc($text) if ($self->in_upper_case());
- $text = $self->xml_protect_text($text);
+ $text = $self->protect_text($text);
if ($self->get_conf('ENABLE_ENCODING') and
!$self->get_conf('ENABLE_ENCODING_USE_ENTITY')
and $self->{'encoding_name'} and $self->{'encoding_name'} eq 'utf-8') {
@@ -3717,7 +3743,7 @@
my $content = shift;
if ($self->in_string()) {
- return $self->xml_protect_text (Texinfo::Convert::Text::convert(
+ return $self->protect_text(Texinfo::Convert::Text::convert(
$command, Texinfo::Common::_convert_text_options($self)));
}
@@ -4160,6 +4186,7 @@
$self->{'commands_formatting'}->{$context}->{$command}
= $Texinfo::Config::commands_formatting{$context}->{$command};
} else {
+ if (defined($default_commands_formatting{$context}->{$command})) {
if ($self->get_conf('ENABLE_ENCODING')
and Texinfo::Convert::Unicode::unicode_for_brace_no_arg_command(
$command, $self->{'encoding_name'})
@@ -4174,6 +4201,7 @@
}
}
}
+ }
# set sane defaults in case there is none and the default formatting
# function is used
@@ -4218,6 +4246,7 @@
foreach my $formatting_references (
['heading_text', \&_default_heading_text, $Texinfo::Config::heading_text],
['comment', \&_default_comment, $Texinfo::Config::comment],
+ ['protect_text', \&_default_protect_text, $Texinfo::Config::protect_text],
['css_lines', \&_default_css_lines, $Texinfo::Config::css_lines],
['begin_file', \&_default_begin_file, $Texinfo::Config::begin_file],
['node_redirection_page', \&_default_node_redirection_page,
@@ -4243,6 +4272,7 @@
['contents', \&_default_contents, $Texinfo::Config::contents],
) {
if (defined($formatting_references->[2])) {
+ # FIXME this pollutes the main converter keys space!
$self->{$formatting_references->[0]} = $formatting_references->[2];
} else {
$self->{$formatting_references->[0]} = $formatting_references->[1];
Index: init/html32.pm
===================================================================
RCS file: init/html32.pm
diff -N init/html32.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ init/html32.pm 8 Oct 2011 20:04:46 -0000 1.1
@@ -0,0 +1,223 @@
+# -*-perl-*-
+#+##############################################################################
+#
+# html32.pm: output HTML 3.2
+#
+# Copyright (C) 2003, 2004, 2007, 2009 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License,
+# or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Originally written by Patrice Dumas.
+#
+#-##############################################################################
+
+use strict;
+use Texinfo::Convert::Converter qw(xml_protect_text);
+
+use vars qw(%commands_formatting %style_commands_formatting $protect_text
+ %commands_conversion %types_conversion);
+
+set_from_init_file('COMPLEX_FORMAT_IN_TABLE', 1);
+
+set_from_init_file('DOCTYPE', '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML
3.2//EN" "http://www.w3.org/TR/html32/loose.dtd">');
+
+set_from_init_file('FRAMESET_DOCTYPE', get_conf('DOCTYPE'));
+
+set_from_init_file('BODYTEXT', 'bgcolor="#FFFFFF" text="#000000"
link="#0000FF" vlink="#800080" alink="#FF0000"');
+
+set_from_init_file('BEFORE_OVERVIEW', '');
+set_from_init_file('AFTER_OVERVIEW', '');
+set_from_init_file('BEFORE_TOC_LINES', '');
+set_from_init_file('AFTER_TOC_LINES', '');
+
+# html version for latex2html
+set_from_init_file('L2H_HTML_VERSION', '3.2');
+
+# no css, no class
+set_from_init_file('NO_CSS', 1);
+
+# no accesskey in html 3.2
+set_from_init_file('USE_ACCESSKEY', 0);
+
+set_from_init_file('MENU_SYMBOL', '*');
+
+set_from_init_file('OPEN_QUOTE_SYMBOL', '`');
+set_from_init_file('CLOSE_QUOTE_SYMBOL', "'");
+
+foreach my $command ('euro', 'geq', 'leq',
+ 'bullet', 'equiv', 'expansion', 'point', 'result', 'arrow',
+ 'quotedblleft', 'quotedblright',
+ 'quoteleft', 'quoteright',
+ 'quotedblbase', 'quotesinglbase', 'guillemetleft', 'guillemetright',
+ 'guillemotleft', 'guillemotright', 'guilsinglleft', 'guilsinglright') {
+
+ $commands_formatting{'normal'}->{$command}
+ = xml_protect_text(undef,
+ $Texinfo::Convert::Text::text_brace_no_arg_commands{$command});
+}
+
+$commands_formatting{'normal'}->{'oe'} = 'œ';
+$commands_formatting{'normal'}->{'OE'} = 'Œ';
+
+foreach my $dots ('dots', 'enddots') {
+ $commands_formatting{'normal'}->{$dots} = '<small>...</small>';
+ $commands_formatting{'preformatted'}->{$dots} = '...';
+}
+
+foreach my $context ('preformatted', 'normal') {
+ foreach my $command('sansserif', 'r') {
+ $style_commands_formatting{$context}->{$command} = {};
+ }
+}
+
+# " is not in html 3.2
+sub html32_protect_text($$)
+{
+ my $converter = shift;
+ my $text = shift;
+ $text =~ s/&/&/g;
+ $text =~ s/</</g;
+ $text =~ s/>/>/g;
+ $text =~ s/\"/"/g;
+ return $text;
+}
+
+$protect_text = \&html32_protect_text;
+
+sub html32_convert_text($$$$)
+{
+ my $self = shift;
+ my $type = shift;
+ my $command = shift;
+ my $text = shift;
+
+ # do that first because in verb and verbatim, type is 'raw'
+ if ($self->in_verbatim()) {
+ return $self->protect_text($text);
+ }
+ return $text if ($type and $type eq 'raw');
+
+ $text = uc($text) if ($self->in_upper_case());
+ $text = $self->protect_text($text);
+
+ if (!$self->in_code() and !$self->in_math()) {
+ $text =~ s/``/"/g;
+ $text =~ s/''/"/g;
+ $text =~ s/---/\x{1F}/g;
+ $text =~ s/--/-/g;
+ $text =~ s/\x{1F}/--/g;
+ }
+ if (!$self->in_preformatted() and $self->in_space_protected()) {
+ $text .= ' ' if (chomp($text));
+ $text =~ s/ / /g;
+ }
+ return $text;
+}
+$types_conversion{'text'} = \&html32_convert_text;
+
+
+sub html32_convert_explained_command($$$$)
+{
+ my $self = shift;
+ my $cmdname = shift;
+ my $command = shift;
+ my $args = shift;
+
+ my $with_explanation;
+
+ return '' if (!$args->[0] or !defined($args->[0]->{'normal'})
+ or $args->[0]->{'normal'} !~ /\S/);
+
+ if ($args->[1] and defined($args->[1]->{'string'})
+ and $args->[1]->{'string'} =~ /\S/) {
+ $with_explanation = 1;
+ }
+
+ my $result;
+ if ($with_explanation) {
+ $result = $self->convert_tree ($self->gdt('{explained_string}
({explanation})',
+ {'explained_string' => $args->[0]->{'tree'},
+ 'explanation' => $args->[1]->{'tree'} }));
+ } else {
+ $result = $args->[0]->{'normal'};
+ }
+ return $result;
+}
+
+foreach my $explained_command (keys(%Texinfo::Common::explained_commands)) {
+ $commands_conversion{$explained_command}
+ = \&html32_convert_explained_command;
+}
+
+# row in multitable. no thead in html 3.2
+sub html32_convert_row_type($$$$) {
+ my $self = shift;
+ my $type = shift;
+ my $command = shift;
+ my $content = shift;
+
+ return $content if ($self->in_string());
+ if ($content =~ /\S/) {
+ return '<tr>' . $content . '</tr>' . "\n";
+ } else {
+ return '';
+ }
+}
+$types_conversion{'row'} = \&html32_convert_row_type;
+
+sub html32_convert_tab_command ($$$$)
+{
+ my $self = shift;
+ my $cmdname = shift;
+ my $command = shift;
+ my $content = shift;
+
+ my $row = $command->{'parent'};
+ my $row_cmdname = $row->{'contents'}->[0]->{'cmdname'};
+
+ # FIXME is it right?
+ $content =~ s/^\s*//;
+ $content =~ s/\s*$//;
+
+ if ($self->in_string()) {
+ return $content;
+ }
+ if ($row_cmdname eq 'headitem') {
+ return "<th>" . $content . '</th>';
+ } else {
+ return "<td>" . $content . '</td>';
+ }
+}
+$commands_conversion{'tab'} = \&html32_convert_tab_command;
+
+sub html32_convert_item_command($$$$)
+{
+ my $self = shift;
+ my $cmdname = shift;
+ my $command = shift;
+ my $content = shift;
+
+ if ($self->in_string()) {
+ return $content;
+ } elsif ($command->{'parent'}->{'type'}
+ and $command->{'parent'}->{'type'} eq 'row') {
+ return html32_convert_tab_command ($self, $cmdname, $command, $content);
+ } else {
+ return &{$self->default_commands_conversion($cmdname)}($self, $cmdname,
$command, $content);
+ }
+}
+$commands_conversion{'item'} = \&html32_convert_item_command;
+$commands_conversion{'headitem'} = \&html32_convert_item_command;
+
+1;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- texinfo/tp Makefile.am Texinfo/Convert/HTML.pm ...,
Patrice Dumas <=