[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
texinfo/tp TODO Texinfo/Parser.pm Texinfo/Conve...
From: |
Patrice Dumas |
Subject: |
texinfo/tp TODO Texinfo/Parser.pm Texinfo/Conve... |
Date: |
Sat, 03 Sep 2011 21:25:41 +0000 |
CVSROOT: /sources/texinfo
Module name: texinfo
Changes by: Patrice Dumas <pertusus> 11/09/03 21:25:41
Modified files:
tp : TODO
tp/Texinfo : Parser.pm
tp/Texinfo/Convert: XML.pm
Log message:
Handle @enumerate, @?table and @itemize.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/TODO?cvsroot=texinfo&r1=1.163&r2=1.164
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Parser.pm?cvsroot=texinfo&r1=1.288&r2=1.289
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/XML.pm?cvsroot=texinfo&r1=1.9&r2=1.10
Patches:
Index: TODO
===================================================================
RCS file: /sources/texinfo/texinfo/tp/TODO,v
retrieving revision 1.163
retrieving revision 1.164
diff -u -b -r1.163 -r1.164
--- TODO 3 Sep 2011 07:26:51 -0000 1.163
+++ TODO 3 Sep 2011 21:25:40 -0000 1.164
@@ -1,10 +1,3 @@
-Enhance @table formatting: group together all the @item
-and @itemx and things in between and group this with
-table_item
-table_entry -> the whole?
-table_term -> all @item?x
-table_item -> the text
-
@appendix should stop @part. Right now it do not do that.
Cf sectioning_part_appendix.
Index: Texinfo/Parser.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Parser.pm,v
retrieving revision 1.288
retrieving revision 1.289
diff -u -b -r1.288 -r1.289
--- Texinfo/Parser.pm 3 Sep 2011 18:02:39 -0000 1.288
+++ Texinfo/Parser.pm 3 Sep 2011 21:25:41 -0000 1.289
@@ -1311,7 +1311,6 @@
unshift @{$table_gathered->{'contents'}}, $item_content;
}
}
- # FIXME TODO Now group @item, inter_item and @itemx in table_term
if ($type eq 'table_item') {
my $table_entry = {'type' => 'table_entry',
'parent' => $current,
Index: Texinfo/Convert/XML.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/XML.pm,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- Texinfo/Convert/XML.pm 3 Sep 2011 07:26:52 -0000 1.9
+++ Texinfo/Convert/XML.pm 3 Sep 2011 21:25:41 -0000 1.10
@@ -17,18 +17,20 @@
#
# Original author: Patrice Dumas <address@hidden>
-# msg Karl: printindex
+# msg Karl: <printindex value="cp"></printindex> instead of
<printindex>cp</printindex>
# <xref> -> xref or pxref or ref
# drop the See
# @findex -> <findex><indexterm
index=\"${index_name}\">${formatted_entry_reference}</indexterm>
-# @abbr do not becomes abbrev
+# @abbr do not becomes abbrev, but stays as abbr
# menu comment -> menucomment
-# menu entry description -> menudescription
+# menu entry description -> menudescription (instead of menucomment)
# preformatted -> pre
-# preamble
+# preamble added
# <tableterm command="item">
# 'command_as_argument' -> apply it?
-# <ftable commandarg="asis">
+# <ftable commandarg="asis"> or <itemize commandarg="bullet">
+# in itemize <itemfunction> -> <itemprepend>?
+# no more <floatpos>
package Texinfo::Convert::XML;
@@ -194,6 +196,7 @@
'alttext', 'imageextension'],
'quotation' => ['quotationtype'],
'float' => ['floatname', 'floattype'],
+ 'itemize' => ['itemfunction'],
);
foreach my $ref_cmd ('pxref', 'xref', 'ref') {
@@ -238,6 +241,8 @@
'menu_entry_description' => 'menudescription',
'menu_entry_name' => 'menutitle',
'preamble' => 'preamble',
+ 'table_item' => 'item',
+ 'table_entry' => 'tableitem',
);
my %context_block_commands = (
@@ -355,6 +360,23 @@
return $command;
}
+sub _index_entry($$)
+{
+ my $self = shift;
+ my $root = shift;
+ if ($root->{'extra'} and $root->{'extra'}->{'index_entry'}) {
+ my $index_entry = $root->{'extra'}->{'index_entry'};
+ my $result = "<indexterm index=\"$index_entry->{'index_name'}\">";
+ push @{$self->{'document_context'}}, {};
+ $self->{'document_context'}->[-1]->{'code'}++
+ if ($index_entry->{'in_code'});
+ $result .= $self->_convert({'contents' => $index_entry->{'content'}});
+ pop @{$self->{'document_context'}};
+ return $result ."</indexterm>"
+ }
+ return '';
+}
+
my @node_directions = ('Next', 'Prev', 'Up');
sub convert($$;$)
@@ -394,7 +416,9 @@
$result =~ s/--/&textndash;/g;
}
}
+ return $result;
}
+ my $close_element;
if ($root->{'cmdname'}) {
if (defined($xml_commands_formatting{$root->{'cmdname'}})) {
if ($root->{'cmdname'} eq 'click'
@@ -409,9 +433,44 @@
if ($root->{'args'} and $root->{'args'}->[0]);
$result .= '</accent>';
return $result;
+ # } elsif ($root->{'cmdname'} eq 'item' and
} elsif ($root->{'cmdname'} eq 'item' or $root->{'cmdname'} eq 'itemx'
or $root->{'cmdname'} eq 'headitem' or $root->{'cmdname'} eq
'tab') {
# TODO
+ if ($root->{'cmdname'} eq 'item'
+ and $root->{'parent'}->{'cmdname'}
+ and ($root->{'parent'}->{'cmdname'} eq 'itemize'
+ or $root->{'parent'}->{'cmdname'} eq 'enumerate')) {
+ $result .= "<item>";
+ $close_element = 'item';
+ } elsif ($root->{'cmdname'} eq 'item' or $root->{'cmdname'} eq 'itemx'
+ and $root->{'parent'}->{'type'}
+ and $root->{'parent'}->{'type'} eq 'table_term') {
+ my $table_command = $root->{'parent'}->{'parent'}->{'parent'};
+ my $format_item_attribute;
+ my $format_item_command;
+ if ($table_command->{'extra'}
+ and $table_command->{'extra'}->{'command_as_argument'}) {
+ $format_item_command
+ = $table_command->{'extra'}->{'command_as_argument'}->{'cmdname'};
+ $format_item_attribute = " itemfunction=\"$format_item_command\"";
+ } else {
+ $format_item_attribute = '';
+ }
+ $result .= "<tableterm
command=\"$root->{'cmdname'}\"${format_item_attribute}>";
+ $result .= $self->_index_entry($root);
+ # FIXME
+ my $in_code;
+ $in_code = 1
+ if ($format_item_command
+ and defined($commands_args_style{$format_item_command})
+ and defined($commands_args_style{$format_item_command}->[0]));
+ $self->{'document_context'}->[-1]->{'code'}++ if ($in_code);
+ $result .= $self->_convert($root->{'args'}->[0]);
+ $self->{'document_context'}->[-1]->{'code'}-- if ($in_code);
+ chomp ($result);
+ $result .= "</tableterm>\n";
+ }
} elsif (exists($xml_misc_commands{$root->{'cmdname'}})) {
my $command;
if (exists ($xml_misc_elements_with_arg_map{$root->{'cmdname'}})) {
@@ -591,6 +650,11 @@
if ($root->{'extra'} and $root->{'extra'}->{'command_as_argument'}) {
$attribute
.= "
commandarg=\"$root->{'extra'}->{'command_as_argument'}->{'cmdname'}\"";
+ } elsif ($root->{'extra'}
+ and $root->{'extra'}->{'enumerate_specification'}) {
+ $attribute .= " first=\""
+
.$self->xml_protect_text($root->{'extra'}->{'enumerate_specification'})
+ ."\"";
}
$result .= "<$root->{'cmdname'}${attribute}>";
if ($root->{'args'} and $commands_args_elements{$root->{'cmdname'}}) {
@@ -617,6 +681,7 @@
}
chomp($result);
$result .= "\n";
+ $close_element = $root->{'cmdname'};
}
}
#} elsif ($root->{'cmdname'} eq 'item'
@@ -689,9 +754,13 @@
and (!$root->{'parent'}->{'type'} or
($root->{'parent'}->{'type'} ne 'block_line_arg'
and $root->{'parent'}->{'type'} ne 'misc_line_arg')));
+ if ($close_element) {
+ $result .= "</$close_element>";
+ }
if ($root->{'cmdname'}
and exists($Texinfo::Common::block_commands{$root->{'cmdname'}})) {
- $result .= "</$root->{'cmdname'}>\n";
+ #$result .= "</$root->{'cmdname'}>\n";
+ $result .= "\n";
if ($context_block_commands{$root->{'cmdname'}}) {
pop @{$self->{'document_context'}};
}
@@ -719,24 +788,12 @@
#set_default('NUMBER_SECTIONS', 0);
-#node special
-
#special -> args -> {type 'misc_arg' , text }
# anchor, node and float -> add a name="->normalized" attribute
-
-#_parse_line_command_args (number of args)
-# 'args' => {'type' => 'misc_line_arg', 'contents' => []}
-# 'extra' => { 'misc_args' => []}
-
+# float
# my $result = "<float name=\"$label_texi\">\n";
-# my $style = $float->{'style'};
-# $style = '' if (!defined($style));
-# $result .= "<floattype>$style</floattype>\n";
-# $result .= "<floatpos></floatpos>\n";
-# $result .= $text;
-# return $result."</float>\n";
# return '<verbatim xml:space="preserve">' . &$protect_text($text) .
'</verbatim>';
@@ -745,20 +802,6 @@
#If prototypes are used, something along
#<columnprototype fraction="0.7">prototy</columnprototype><columnprototype
fraction="0.5">pro</columnprototype>
-#<nodenext explicit="on">next node</nodenext>
-
-#<table><tableitem><item>@item<item>
-#<item>@itemx</item> </tableitem>
-#<tableterm>$text ."</tableterm>\n";
-#sub xml_table_line($)
-# return "<item>$text</item>" unless $only_inter_item_commands;
-#
-# $result .= $text ."</tableterm>\n";
-
-
-#sub xml_list_item($$$$$$$$$)
-# return '<item>' . $text . "</item>\n";
-#
#sub xml_row($$;$$)
#<thead>@headitem ... </thead>
#<tbody>@item... </tbody>
@@ -766,19 +809,10 @@
#cell
# return "<entry>" . $text . '</entry>';
-#
-#<$format_command>
-#itemize
-#<itemfunction>$itemfunction</itemfunction>
-#enumerate
-#<$format_command first=\"$enumerate_style\">
# $complex_format_map{$complex_format}->{'begin'} = "<$complex_format
xml:space=\"preserve\">";
# $complex_format_map{$complex_format}->{'end'} = "</$complex_format>";
-#xml_index_entry_label
-# return "<indexterm
index=\"${index_name}\">${formatted_entry_reference}</indexterm>";
-
# my $tag = 'inlineimage';
# $tag = 'image' if ($preformatted or !$in_paragraph);
# return "<$tag width=\"$width\" height=\"$height\" name=\"".
&$protect_text($base)."\"
extension=\"$extension\"><alttext>$alt</alttext></$tag>";