[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
texinfo/tp TODO Texinfo/Convert/HTML.pm Texinfo...
From: |
Patrice Dumas |
Subject: |
texinfo/tp TODO Texinfo/Convert/HTML.pm Texinfo... |
Date: |
Mon, 15 Aug 2011 12:53:25 +0000 |
CVSROOT: /sources/texinfo
Module name: texinfo
Changes by: Patrice Dumas <pertusus> 11/08/15 12:53:25
Modified files:
tp : TODO
tp/Texinfo/Convert: HTML.pm Plaintext.pm
Log message:
Handle correctly menu within a preformatted.
Handle SIMPLE_MENU as a menu within preformatted for now.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/TODO?cvsroot=texinfo&r1=1.154&r2=1.155
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/HTML.pm?cvsroot=texinfo&r1=1.131&r2=1.132
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Plaintext.pm?cvsroot=texinfo&r1=1.152&r2=1.153
Patches:
Index: TODO
===================================================================
RCS file: /sources/texinfo/texinfo/tp/TODO,v
retrieving revision 1.154
retrieving revision 1.155
diff -u -b -r1.154 -r1.155
--- TODO 13 Aug 2011 20:19:10 -0000 1.154
+++ TODO 15 Aug 2011 12:53:24 -0000 1.155
@@ -4,9 +4,6 @@
(*note Inserting Quotation Marks::).
-l 3273 in HTML.pm don't be in preformatted for the description.
-but call the function for the other stuff.
-
remove _*directions('This' and replace with new API. Done?
There should be an error message (report by Tom Tromey) in
Index: Texinfo/Convert/HTML.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/HTML.pm,v
retrieving revision 1.131
retrieving revision 1.132
diff -u -b -r1.131 -r1.132
--- Texinfo/Convert/HTML.pm 14 Aug 2011 23:04:01 -0000 1.131
+++ Texinfo/Convert/HTML.pm 15 Aug 2011 12:53:25 -0000 1.132
@@ -108,12 +108,16 @@
return $self->{'document_context'}->[-1]->{'math'};
}
+# set if in menu or preformatted command
sub in_preformatted($)
{
my $self = shift;
my $context =
$self->{'document_context'}->[-1]->{'composition_context'}->[-1];
- return ($preformatted_commands{$context}
- or ($menu_commands{$context} and $self->get_conf('SIMPLE_MENU')));;
+ if ($preformatted_commands{$context} or $menu_commands{$context}) {
+ return $context;
+ } else {
+ return undef;
+ }
}
sub in_upper_case($)
@@ -176,10 +180,16 @@
return @{$self->{'document_context'}->[-1]->{'preformatted_classes'}};
}
-sub align($)
+sub in_align($)
{
my $self = shift;
- return $self->{'document_context'}->[-1]->{'composition_context'}->[-1];
+ my $context
+ = $self->{'document_context'}->[-1]->{'composition_context'}->[-1];
+ if ($align_commands{$context}) {
+ return $context;
+ } else {
+ return undef;
+ }
}
sub _get_target($$)
@@ -2365,6 +2375,17 @@
}
$default_commands_conversion{'listoffloats'} = \&_convert_listoffloats_command;
+sub _in_preformatted_in_menu($)
+{
+ my $self = shift;
+ return 1 if ($self->get_conf('SIMPLE_MENU'));
+ my @pre_classes = $self->preformatted_classes_stack();
+ foreach my $pre_class (@pre_classes) {
+ return 1 if ($preformatted_commands{$pre_class});
+ }
+ return 0;
+}
+
my $html_menu_entry_index;
sub _convert_menu_command($$$$)
{
@@ -2381,7 +2402,10 @@
}
my $begin_row = '';
my $end_row = '';
- if ($self->in_preformatted()) {
+ if ($self->_in_preformatted_in_menu()) {
+ #my $pre_class = $self->_preformatted_class();
+ #return $self->attribute_class('pre', $pre_class).">".$content."</pre>";
+
$begin_row = '<tr><td>';
$end_row = '</td></tr>';
}
@@ -3194,8 +3218,8 @@
}
if ($content =~ /\S/) {
- my $align = $self->align();
- if ($paragraph_style{$align}) {
+ my $align = $self->in_align();
+ if ($align and $paragraph_style{$align}) {
return "<p align=\"$paragraph_style{$align}\">".$content."</p>";
} else {
return "<p>".$content."</p>";
@@ -3207,6 +3231,22 @@
$default_types_conversion{'paragraph'} = \&_convert_paragraph_type;
+sub _preformatted_class()
+{
+ my $self = shift;
+ my $pre_class;
+ my @pre_classes = $self->preformatted_classes_stack();
+ foreach my $class (@pre_classes) {
+ # FIXME maybe add or $pre_class eq 'menu-preformatted' to override
+ # 'menu-preformatted' with 'menu-comment'?
+ $pre_class = $class unless ($pre_class
+ and $preformatted_code_commands{$pre_class}
+ and !($preformatted_code_commands{$class}
+ or $class eq 'menu-preformatted'));
+ }
+ return $pre_class;
+}
+
sub _convert_preformatted_type($$$$)
{
my $self = shift;
@@ -3220,7 +3260,7 @@
}
my $current = $command;
- my $pre_class;
+
# !defined preformatted_number may happen if there is something before the
# first preformatted. For example an @exdent.
if ($self->preformatted_number() and $self->preformatted_number() == 1) {
@@ -3230,15 +3270,7 @@
return '' if ($content eq '');
- my @pre_classes = $self->preformatted_classes_stack();
- foreach my $class (@pre_classes) {
- # FIXME maybe add or $pre_class eq 'menu-preformatted' to override
- # 'menu-preformatted' with 'menu-comment'?
- $pre_class = $class unless ($pre_class
- and $preformatted_code_commands{$pre_class}
- and !($preformatted_code_commands{$class}
- or $class eq 'menu-preformatted'));
- }
+ my $pre_class = $self->_preformatted_class();
#while ($current->{'parent'}) {
# $current = $current->{'parent'};
# if ($current->{'cmdname'} and $pre_class_commands{$current->{'cmdname'}})
{
@@ -3255,7 +3287,8 @@
$content =~ s/\s*$//;
}
if ($command->{'parent'}->{'type'}
- and $command->{'parent'}->{'type'} eq 'menu_entry_description') {
+ and $command->{'parent'}->{'type'} eq 'menu_entry_description'
+ and !$self->_in_preformatted_in_menu()) {
return $content;
}
my $result = $self->attribute_class('pre', $pre_class).">".$content."</pre>";
@@ -3413,10 +3446,14 @@
my $MENU_SYMBOL = $self->get_conf('MENU_SYMBOL');
my $MENU_ENTRY_COLON = $self->get_conf('MENU_ENTRY_COLON');
- if ($self->in_preformatted()) {
+ if ($self->_in_preformatted_in_menu()) {
my $result = '';
my $i = 0;
- foreach my $arg (@{$command->{'args'}}) {
+ my @args = @{$command->{'args'}};
+ while (@args) {
+ last if ($args[0]->{'type'}
+ and $args[0]->{'type'} eq 'menu_entry_description');
+ my $arg = shift @args;
if ($arg->{'type'} and $arg->{'type'} eq 'menu_entry_node') {
my $name = $self->convert_tree(
{'type' => '_code', 'contents' => $arg->{'contents'}});
@@ -3435,9 +3472,19 @@
}
$i++;
}
- return &{$self->{'types_conversion'}->{'preformatted'}}($self,
- 'preformatted_in_menu_entry',
- {'type' => 'preformatted', 'parent' => $command->{'parent'}}, $result);
+ #my $menu_entry = &{$self->{'types_conversion'}->{'preformatted'}}($self,
+ # 'preformatted_in_menu_entry',
+ # {'type' => 'preformatted', 'parent' => $command->{'parent'}}, $result);
+ my $description = '';
+ foreach my $arg (@args) {
+ $description .= $self->convert_tree($arg, "menu_arg preformatted [$i]");
+ $i++;
+ }
+ $description =~ s/^<pre[^>]*>//;
+ $description =~ s/<\/pre>$//;
+
+ my $pre_class = $self->_preformatted_class();
+ return $self->attribute_class('pre', $pre_class).">".$result .
$description."</pre>";
}
my $name;
@@ -3512,7 +3559,7 @@
my $command = shift;
my $content = shift;
- if ($self->in_preformatted()) {
+ if ($self->_in_preformatted_in_menu()) {
return $content;
} else {
return "<tr><th colspan=\"3\" align=\"left\" valign=\"top\">".$content
@@ -6168,29 +6215,6 @@
return $text;
}
-
-# on top, the converter object which holds some global information
-#
-# context (for footnotes, multitable cells):
-# 'preformatted'
-# 'max'
-#
-# format_context
-# indentation + count for prepending text
-# also paragraph count and maybe empty line count
-#
-# containers on their own stack
-# in container
-# 'upper_case'
-# 'code'
-#
-# paragraph number: incremented with block commands except html and such
-# and group and raggedright and menu*
-# and also center and listoffloats
-# and with paragraphs.
-
-# preformatted
-
sub _convert($$;$);
sub _convert($$;$)
Index: Texinfo/Convert/Plaintext.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Plaintext.pm,v
retrieving revision 1.152
retrieving revision 1.153
diff -u -b -r1.152 -r1.153
--- Texinfo/Convert/Plaintext.pm 14 Aug 2011 23:04:01 -0000 1.152
+++ Texinfo/Convert/Plaintext.pm 15 Aug 2011 12:53:25 -0000 1.153
@@ -101,7 +101,7 @@
}
# There are 5 stacks that define the context.
-# 'context': relevant for alignement of text. Set in math, footnote,
+# context: relevant for alignement of text. Set in math, footnote,
# listoffloats, flush_commands, preformatted_context_commands
# (preformatted + menu + verbatim), and raw commands if
# on top level.
@@ -115,9 +115,10 @@
# position (although the counter in the line is taken over by
# the formatter once a formatter is opened).
# Set in footnote and in multitable cells.
-# formatters: the current objects that does the counting of columns,
-# actual indentation. In general, it is better not to have
-# formatters in parallel, but it may happen.
+# formatters: a formatter environment has stacks for formatting context.
+# Also holds a container, an objects that does the counting
+# of columns, actual indentation. In general, it is better not
+# to have formatters in parallel, but it may happen.
# count_context: holds the bytes count, the lines count and the location
# of the commands that have their byte count or llines count
# recorded. It is set for out of document formatting to avoid
@@ -125,6 +126,14 @@
# to be modified afterwards, for aligned commands or multitable
# cells for example.
+# formatters have their own stack
+# in container
+# 'upper_case'
+# 'code'
+#
+# paragraph number incremented with paragraphs, center, listoffloats
+#Â and block commands except: html and such, group, raggedright, menu*, float
+
my %default_preformatted_context_commands = %preformatted_commands;
foreach my $preformatted_command ('verbatim', keys(%menu_commands)) {
$default_preformatted_context_commands{$preformatted_command} = 1;
@@ -1031,28 +1040,6 @@
return ('', 0);
}
-# on top, the converter object which holds some global information
-#
-# context (for footnotes, multitable cells):
-# 'preformatted'
-# 'max'
-#
-# format_context
-# indentation + count for prepending text
-# also paragraph count and maybe empty line count
-#
-# containers on their own stack
-# in container
-# 'upper_case'
-# 'code'
-#
-# paragraph number: incremented with block commands except html and such
-# and group and raggedright and menu*
-# and also center and listoffloats
-# and with paragraphs.
-
-# preformatted
-
sub _convert($$);
sub _convert($$)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- texinfo/tp TODO Texinfo/Convert/HTML.pm Texinfo...,
Patrice Dumas <=